<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
abstract class Engine_Vfs_Object_Abstract implements Engine_Vfs_Object_Interface
{
  protected $_adapter;

  protected $_path;

  protected $_mode;

  protected $_resource;

  public function __construct(Engine_Vfs_Adapter_Interface $adapter, $path, $mode = 'r')
  {
    $this->_adapter = $adapter;
    $this->_path = $path;
    $this->_mode = $mode;
    $this->open($mode);
  }

  public function getPath()
  {
    return $this->_path;
  }

  public function getMode()
  {
    return $this->_mode;
  }

  public function getResource()
  {
    if( !$this->_resource ) {
      throw new Engine_Vfs_Object_Exception('No resource');
    }
    return $this->_resource;
  }

  public function getFileInfo()
  {
    return $this->_adapter->info($this->_path);
  }
}
