setType() public method

public setType ( string $type )
$type string
Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 public function getFile($path)
 {
     $file = new \Jarves\File\FileInfo();
     $file->setPath($path ?: '/');
     $path = $this->getFullPath($path ?: '/');
     if (!file_exists($path)) {
         throw new FileNotFoundException(sprintf('File `%s` does not exists.', $path));
     }
     if (!is_readable($path)) {
         throw new FileNotFoundException(sprintf('File `%s` is not readable.', $path));
     }
     $file->setType(is_dir($path) ? 'dir' : 'file');
     $file->setCreatedTime(filectime($path));
     $file->setModifiedTime(filectime($path));
     $file->setSize(filesize($path));
     return $file;
 }
Esempio n. 2
0
 /**
  * @param string $path
  * @return \Jarves\Model\File[]
  */
 public function getFiles($path)
 {
     $items = parent::getFiles($path);
     $fs = $this->getAdapter($path);
     if ($fs->getMountPath()) {
         foreach ($items as &$file) {
             $file->setMountPoint($fs->getMountPath());
         }
     }
     if ('/' === $path) {
         foreach ($this->jarvesConfig->getSystemConfig()->getMountPoints() as $mountPoint) {
             $fileInfo = new FileInfo();
             $fileInfo->setPath('/' . $mountPoint->getPath());
             //                $fileInfo->setIcon($mountPoint->getIcon());
             $fileInfo->setType(FileInfo::DIR);
             $fileInfo->setMountPoint(true);
             array_unshift($items, $fileInfo);
         }
     }
     return $this->wrap($items);
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function getFiles($path)
 {
     $path = $this->getFullPath($path);
     $path = str_replace('..', '', $path);
     if (!file_exists($path)) {
         throw new FileNotFoundException(sprintf('File `%s` does not exists.', $path));
     }
     if (!is_dir($path)) {
         throw new NotADirectoryException(sprintf('File `%s` is not a directory.', $path));
     }
     if (substr($path, -1) != '/') {
         $path .= '/';
     }
     $h = @opendir($path);
     if (!$h) {
         throw new \Exception(sprintf('Can not open `%s`. Probably no permissions.', $path));
     }
     $items = array();
     while ($file = readdir($h)) {
         $fileInfo = new FileInfo();
         if ($file == '.' || $file == '..') {
             continue;
         }
         $file = $path . $file;
         $fileInfo->setPath(substr($file, strlen($this->getRoot()) - 1));
         $fileInfo->setType(is_dir($file) ? FileInfo::DIR : FileInfo::FILE);
         if (!is_link($file)) {
             $fileInfo->setCreatedTime(filectime($file));
             $fileInfo->setModifiedTime(filemtime($file));
             if (is_file($file)) {
                 $fileInfo->setSize(filesize($file));
             }
         }
         $items[] = $fileInfo;
     }
     return $items;
 }