/**
  * Returns a new (child of) sfFilebasePluginFile. It returns an instance,
  * not regarding if the file exists or not. So you can fetch an instance
  * and create the underlying file by sfFilebasePlugin-methods.
  *
  * This method checks if file is a directory, an image
  * a link ... but beware, some attributes can only
  * be calculated if the file really exists in file system.
  *
  * For example, if you want to retrieve a directory that does
  * not exists, an instance of sfFilebasePluginFile is recieved.
  *
  * This behavior is simple and logically correct, but you have to keep it in
  * mind: sfFilebasePlugin cannot forecast what files you want to create. It
  * is probably more confusing for windows users where files are mostly
  * identified by its extension.
  *
  * If the dir exists, you'll get a sfFilebasePluginDirectory.
  *
  * @example $filebase->getFilebaseFile('path/to/directory') retrieves a dir
  *          if it exists in FS, or a sfFilebaseFile if not.
  *
  * @example Creating a new file:
  *          $new_file = $filebase->getFilebaseFile('path/to/new/file.txt');
  *          $filebase->touch($new_file);
  *          In Short: $filebase->touch('path/to/new/file.txt');
  *
  * @example Short way retrieving files:
  *          foreach ($filebase AS $file) ...
  *          with ArrayAccess:
  *          $file = $filebase['/path/to/file'];
  *
  * @todo Implement (sym)link handling.
  * @param string | sfFilebasePluginFile  $filename
  * @return sfFilebasePluginFile
  */
 public function getFilebaseFile($filename)
 {
     if (is_string($filename)) {
         //$filename = sfFilebasePluginUtil::unifySlashes($filename);
         if (strlen($filename) > 0) {
             if (sfFilebasePluginUtil::isAbsolutePathname($filename)) {
                 $filename = new sfFilebasePluginFile($filename, $this->filebase);
             } else {
                 $filename = new sfFilebasePluginFile($this->getPathname() . '/' . $filename, $this->filebase);
             }
         } else {
             $filename = $this;
         }
     }
     if ($filename instanceof sfFilebasePluginFile) {
         // returns only true if file exists, so beware of that
         if ($filename->isLink()) {
             throw new sfFilebasePluginException(sprintf('Error retrieving link %s: Link handling is not yet implemented', $filename->getPathname()));
             //return new sfFilebasePluginLink($filename->getPathname());
         } elseif ($filename->isDir()) {
             $filename = new sfFilebasePluginDirectory($filename->getPathname(), $this->filebase);
         } elseif ($this->filebase->getIsWebImage($filename)) {
             $filename = new sfFilebasePluginImage($filename->getPathname(), $this->filebase);
         }
         return $filename;
     }
     throw new sfFilebasePluginException(sprintf('File %s must be of type [string] or instanceof FilebaseFile', $filename));
 }
 /**
  * Returns true if sfFilebasePluginFile is a
  * <strong>web</strong> image file. Used to factory
  * a sfFilebasePluginImage instance by sfFilebasePlugin::
  * getFilebaseFile()
  *
  * @see sfFilebasePlugin::getIsWebImage()
  * @todo improved mime-type detection
  * @return boolean true if file is an image
  */
 public function isWebImage()
 {
     return $this->filebase->getIsWebImage($this);
 }