<?php

/**
 * Subclass for representing a row from the 'tblspaceresource' table.
 *
 * 
 *
 * @package lib.model
 */ 
class Tblspaceresource extends BaseTblspaceresource
{
	/**
	 * Initializes internal state of Tblspaceresource object.
	 * @see        parent::__construct()
	 */
	public function __construct()
	{
		// Make sure that parent constructor is always invoked, since that
		// is where any default values for this object are set.
		parent::__construct();
	}

  private function getResPath($create = false) {
    $resId = $this->getResId();
    $path = violetUtil::getSpacePath(true) . floor($resId/1000).'/'.$resId;
    if ($create && !file_exists($path)) mkdir($path, 0777, true);
    return $path;
  }

  public function getFullFilename($create = false) {
    return $this->getResPath($create).'/'.$this->getResFilename();
  }

  public function delete(PropelPDO $con = null) {
    $path = $this->getResPath();
    unlink($path.'/'.$this->getResFilename());
    rmdir($path);
    parent::delete($con);
  }
}
