当前位置: 首页>>代码示例>>PHP>>正文


PHP SplFileInfo::isDir方法代码示例

本文整理汇总了PHP中SplFileInfo::isDir方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::isDir方法的具体用法?PHP SplFileInfo::isDir怎么用?PHP SplFileInfo::isDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SplFileInfo的用法示例。


在下文中一共展示了SplFileInfo::isDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 public function render($view = null, $layout = null)
 {
     try {
         ob_start();
         if (defined('DOMPDF_TEMP_DIR')) {
             $dir = new SplFileInfo(DOMPDF_TEMP_DIR);
             if (!$dir->isDir() || !$dir->isWritable()) {
                 trigger_error(__('%s is not writable', DOMPDF_TEMP_DIR), E_USER_WARNING);
             }
         }
         $errors = ob_get_contents();
         ob_end_clean();
         $download = false;
         $name = pathinfo($this->here, PATHINFO_BASENAME);
         $paperOrientation = 'portrait';
         $paperSize = 'letter';
         extract($this->viewVars, EXTR_IF_EXISTS);
         $dompdf = new DOMPDF();
         $dompdf->load_html($errors . parent::render($view, $layout), Configure::read('App.encoding'));
         $dompdf->set_protocol('');
         $dompdf->set_protocol(WWW_ROOT);
         $dompdf->set_base_path('/');
         $dompdf->set_paper($paperSize, $paperOrientation);
         $dompdf->render();
         $dompdf->stream($name, array('Attachment' => $download));
     } catch (Exception $e) {
         $this->request->params['ext'] = 'html';
         throw $e;
     }
 }
开发者ID:raunakbinani,项目名称:cakephp-dompdf-view,代码行数:30,代码来源:PdfView.php

示例2: upload

 /**
  * Upload (move) file to branch logos directory
  * @param UploadedFile $logo
  * @param null|string $targetFilename
  * @return \Symfony\Component\HttpFoundation\File\File
  * @throws LogoHandlerLogicException
  */
 public function upload(UploadedFile $logo, $targetFilename = null)
 {
     if (!in_array($logo->getMimeType(), $this->permittedMimeTypes)) {
         throw new LogoHandlerLogicException(sprintf('"%s" file type is not permitted. Use images for logo and try again.', $logo->getMimeType()));
     }
     if (is_null($targetFilename)) {
         $targetFilename = sha1(uniqid(mt_rand(), true)) . '.' . $logo->guessExtension();
     }
     if (false === $this->branchLogoDir->isDir() || false === $this->branchLogoDir->isWritable()) {
         throw new \RuntimeException(sprintf("Branch logo directory (%s) is not writable, doesn't exist or no space left on the disk.", $this->branchLogoDir->getRealPath()));
     }
     return $logo->move($this->branchLogoDir->getRealPath(), $targetFilename);
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:20,代码来源:BranchLogoHandler.php

示例3: isIgnored

 protected static function isIgnored(\SplFileInfo $file, $ignore)
 {
     if (in_array($file->getFilename(), static::$IGNORED)) {
         return true;
     }
     if ($file->isDir() && in_array($file->getFilename(), $ignore['folders'])) {
         return true;
     }
     if (!$file->isDir() && in_array($file->getFilename(), $ignore['files'])) {
         return true;
     }
     return false;
 }
开发者ID:ArkadiuszMichalRys,项目名称:Docs,代码行数:13,代码来源:Builder.php

示例4: isIgnored

 protected static function isIgnored(\SplFileInfo $file, $ignore)
 {
     $filename = $file->getFilename();
     if (in_array($filename, static::$IGNORED)) {
         return true;
     }
     if (array_key_exists('folders', $ignore) && $file->isDir() && in_array($filename, $ignore['folders'])) {
         return true;
     }
     if (array_key_exists('files', $ignore) && !$file->isDir() && in_array($filename, $ignore['files'])) {
         return true;
     }
     return false;
 }
开发者ID:justinwalsh,项目名称:daux.io,代码行数:14,代码来源:Builder.php

示例5: write

 /**
  * Writes the class to a file.
  */
 public function write()
 {
     try {
         $dir = $this->path->isDir() ? $this->path->getPathname() : $this->path->getPath();
         $path = $dir . '/' . $this->baseClass->getClassName() . $this->baseClass->getExtension();
         if (!file_exists($dir)) {
             $this->fileSystem->mkdir($dir, 0777, true);
         }
         //if (!file_exists($path)) {
         file_put_contents($path, $this->baseClass->generate());
         //}
     } catch (IOExceptionInterface $e) {
     }
 }
开发者ID:jdgriffith,项目名称:ImagineBundle,代码行数:17,代码来源:ClassWriter.php

示例6: upload

 /**
  * Upload (move to target dir) given file
  * @param string $filename
  * @param string $content
  * @return string path to filename
  */
 public function upload($filename, $content)
 {
     if (false === $this->uploadDir->isDir()) {
         try {
             $this->fs->mkdir($this->uploadDir->getPathname());
         } catch (\Exception $e) {
             throw new \RuntimeException('Upload directory is not writable, doesn\'t exist or no space left on the disk.');
         }
     }
     if (false === $this->uploadDir->isWritable()) {
         throw new \RuntimeException('Upload directory is not writable, doesn\'t exist or no space left on the disk.');
     }
     $this->fs->dumpFile($this->uploadDir->getRealPath() . '/' . $filename, $content);
     return $this->uploadDir->getRealPath() . '/' . $filename;
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:21,代码来源:LocalFileStorageService.php

示例7: setStoragePath

 /**
  * Set path to user files storage
  * @param $path
  * @throws \Exception
  */
 public function setStoragePath($path)
 {
     $this->storagePath = new SplFileInfo($path);
     if (!$this->storagePath->isDir()) {
         throw new \Exception(__METHOD__ . ' | ' . 'storage path is not directory or does not exist.');
     }
 }
开发者ID:ysaroka,项目名称:uploader,代码行数:12,代码来源:UserFileStorage.php

示例8: isDir

 /**
  */
 public function isDir()
 {
     if (null === $this->d) {
         $this->d = parent::isDir();
     }
     return $this->d;
 }
开发者ID:shads196770,项目名称:cbox-theme,代码行数:9,代码来源:file.php

示例9: make_writable

 /**
  * This function will make directory writable.
  *
  * @param   string  path
  * @return  void
  * @throw   Kohana_Exception
  */
 public static function make_writable($path, $chmod = NULL)
 {
     try {
         $dir = new SplFileInfo($path);
         if ($dir->isFile()) {
             throw new Kohana_Exception('Could not make :path writable directory because it is regular file', array(':path' => Debug::path($path)));
         } elseif ($dir->isLink()) {
             throw new Kohana_Exception('Could not make :path writable directory because it is link', array(':path' => Debug::path($path)));
         } elseif (!$dir->isDir()) {
             // Try create directory
             Ku_Dir::make($path, $chmod);
             clearstatcache(TRUE, $path);
         }
         if (!$dir->isWritable()) {
             // Try make directory writable
             chmod($dir->getRealPath(), $chmod === NULL ? Ku_Dir::$default_dir_chmod : $chmod);
             clearstatcache(TRUE, $path);
             // Check result
             if (!$dir->isWritable()) {
                 throw new Exception('Make dir writable failed', 0);
             }
         }
     } catch (Kohana_Exception $e) {
         // Rethrow exception
         throw $e;
     } catch (Exception $e) {
         throw new Kohana_Exception('Could not make :path directory writable', array(':path' => Debug::path($path)));
     }
 }
开发者ID:greor,项目名称:satin-spb,代码行数:36,代码来源:dir.php

示例10: upload

 /**
  * Upload an image to local server then return new image path after upload success
  * 
  * @param array $file [tmp_name, name, error, type, size] 
  * @param string image path for saving (this may constain filename)
  * @param string image filename for saving
  * @return string Image path after uploaded
  * @throws Exception If upload failed
  */
 public function upload($file, $newImagePath = '.', $newImageName = NULL)
 {
     if (!empty($file['error'])) {
         $this->_throwException(':method: Upload error. Number: :number', array(':method' => __METHOD__, ':number' => $file['error']));
     }
     if (getimagesize($file['tmp_name']) === FALSE) {
         $this->_throwException(':method: The file is not an image file.', array(':method' => __METHOD__));
     }
     $fileInfo = new \SplFileInfo($newImagePath);
     if (!$fileInfo->getRealPath() or !$fileInfo->isDir()) {
         $this->_throwException(':method: The ":dir" must be a directory.', array(':method' => __METHOD__, ':dir' => $newImagePath));
     }
     $defaultExtension = '.jpg';
     if (empty($newImageName)) {
         if (!in_array($fileInfo->getBasename(), array('.', '..')) and $fileInfo->getExtension()) {
             $newImageName = $fileInfo->getBasename();
         } else {
             $newImageName = uniqid() . $defaultExtension;
         }
     }
     if (!$fileInfo->isWritable()) {
         $this->_throwException(':method: Directory ":dir" is not writeable.', array(':method' => __METHOD__, ':dir' => $fileInfo->getRealPath()));
     }
     $destination = $fileInfo->getRealPath() . DIRECTORY_SEPARATOR . $newImageName;
     if (move_uploaded_file($file['tmp_name'], $destination)) {
         return $destination;
     } else {
         $this->_throwException(':method: Cannot move uploaded file to :path', array(':method' => __METHOD__, ':path' => $fileInfo->getRealPath()));
     }
 }
开发者ID:0hyeah,项目名称:yurivn,代码行数:39,代码来源:Local.php

示例11: __construct

 /**
  * @param \SplFileInfo $file
  */
 public function __construct(\SplFileInfo $file)
 {
     if (!$file->isDir()) {
         throw new \InvalidArgumentException('Expecting directory');
     }
     $this->iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($file->getPathname(), \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS));
 }
开发者ID:continuousphp,项目名称:deploy-agent,代码行数:10,代码来源:RecursiveDirectoryAggregate.php

示例12: deployArchive

 /**
  * (non-PHPdoc)
  *
  * @param \AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface $containerNode The container the archive belongs to
  * @param \SplFileInfo                                                $archive       The archive file to be deployed
  *
  * @return void
  * @see \AppserverIo\Appserver\Core\AbstractExtractor::deployArchive()
  */
 public function deployArchive(ContainerNodeInterface $containerNode, \SplFileInfo $archive)
 {
     try {
         // create folder names based on the archive's basename
         $tmpFolderName = new \SplFileInfo($this->getTmpDir($containerNode) . DIRECTORY_SEPARATOR . $archive->getFilename());
         $webappFolderName = new \SplFileInfo($this->getWebappsDir($containerNode) . DIRECTORY_SEPARATOR . basename($archive->getFilename(), $this->getExtensionSuffix()));
         // check if archive has not been deployed yet or failed sometime
         if ($this->isDeployable($archive)) {
             // flag webapp as deploying
             $this->flagArchive($archive, ExtractorInterface::FLAG_DEPLOYING);
             // backup actual webapp folder, if available
             if ($webappFolderName->isDir()) {
                 // backup files that are NOT part of the archive
                 $this->backupArchive($containerNode, $archive);
                 // delete directories previously backed up
                 $this->removeDir($webappFolderName);
             }
             // remove old temporary directory
             $this->removeDir($tmpFolderName);
             // initialize a \Phar instance
             $p = new \Phar($archive);
             // create a recursive directory iterator
             $iterator = new \RecursiveIteratorIterator($p);
             // unify the archive filename, because Windows uses a \ instead of /
             $archiveFilename = sprintf('phar://%s', str_replace(DIRECTORY_SEPARATOR, '/', $archive->getPathname()));
             // iterate over all files
             foreach ($iterator as $file) {
                 // prepare the temporary filename
                 $target = $tmpFolderName . str_replace($archiveFilename, '', $file->getPathname());
                 // create the directory if necessary
                 if (file_exists($directory = dirname($target)) === false) {
                     if (mkdir($directory, 0755, true) === false) {
                         throw new \Exception(sprintf('Can\'t create directory %s', $directory));
                     }
                 }
                 // finally copy the file
                 if (copy($file, $target) === false) {
                     throw new \Exception(sprintf('Can\'t copy %s file to %s', $file, $target));
                 }
             }
             // move extracted content to webapps folder and remove temporary directory
             FileSystem::copyDir($tmpFolderName->getPathname(), $webappFolderName->getPathname());
             FileSystem::removeDir($tmpFolderName->getPathname());
             // we need to set the user/rights for the extracted folder
             $this->setUserRights($webappFolderName);
             // restore backup if available
             $this->restoreBackup($containerNode, $archive);
             // flag webapp as deployed
             $this->flagArchive($archive, ExtractorInterface::FLAG_DEPLOYED);
             // log a message that the application has successfully been deployed
             $this->getInitialContext()->getSystemLogger()->info(sprintf('Application archive %s has succussfully been deployed', $archive->getBasename($this->getExtensionSuffix())));
         }
     } catch (\Exception $e) {
         // log error
         $this->getInitialContext()->getSystemLogger()->error($e->__toString());
         // flag webapp as failed
         $this->flagArchive($archive, ExtractorInterface::FLAG_FAILED);
     }
 }
开发者ID:appserver-io,项目名称:appserver,代码行数:68,代码来源:PharExtractor.php

示例13: __construct

 public function __construct(SplFileInfo $fileInfo)
 {
     $this->perms = $fileInfo->getPerms();
     $this->size = $fileInfo->getSize();
     $this->is_dir = $fileInfo->isDir();
     $this->is_file = $fileInfo->isFile();
     $this->is_link = $fileInfo->isLink();
     if (($this->perms & 0xc000) === 0xc000) {
         $this->typename = 'File socket';
         $this->typeflag = 's';
     } elseif ($this->is_file) {
         if ($this->is_link) {
             $this->typename = 'File symlink';
             $this->typeflag = 'l';
         } else {
             $this->typename = 'File';
             $this->typeflag = '-';
         }
     } elseif (($this->perms & 0x6000) === 0x6000) {
         $this->typename = 'Block special file';
         $this->typeflag = 'b';
     } elseif ($this->is_dir) {
         if ($this->is_link) {
             $this->typename = 'Directory symlink';
             $this->typeflag = 'l';
         } else {
             $this->typename = 'Directory';
             $this->typeflag = 'd';
         }
     } elseif (($this->perms & 0x2000) === 0x2000) {
         $this->typename = 'Character special file';
         $this->typeflag = 'c';
     } elseif (($this->perms & 0x1000) === 0x1000) {
         $this->typename = 'FIFO pipe file';
         $this->typeflag = 'p';
     }
     parent::__construct('FsPath');
     $this->path = $fileInfo->getPathname();
     $this->realpath = realpath($this->path);
     if ($this->is_link && method_exists($fileInfo, 'getLinktarget')) {
         $this->linktarget = $fileInfo->getLinktarget();
     }
     $flags = array($this->typeflag);
     // User
     $flags[] = $this->perms & 0x100 ? 'r' : '-';
     $flags[] = $this->perms & 0x80 ? 'w' : '-';
     $flags[] = $this->perms & 0x40 ? $this->perms & 0x800 ? 's' : 'x' : ($this->perms & 0x800 ? 'S' : '-');
     // Group
     $flags[] = $this->perms & 0x20 ? 'r' : '-';
     $flags[] = $this->perms & 0x10 ? 'w' : '-';
     $flags[] = $this->perms & 0x8 ? $this->perms & 0x400 ? 's' : 'x' : ($this->perms & 0x400 ? 'S' : '-');
     // Other
     $flags[] = $this->perms & 0x4 ? 'r' : '-';
     $flags[] = $this->perms & 0x2 ? 'w' : '-';
     $flags[] = $this->perms & 0x1 ? $this->perms & 0x200 ? 't' : 'x' : ($this->perms & 0x200 ? 'T' : '-');
     $this->contents = implode($flags);
 }
开发者ID:jnvsor,项目名称:kint,代码行数:57,代码来源:FsPath.php

示例14: isVideo

 /**
  * 
  * @param \SplFileInfo $file
  * @return boolean
  */
 protected function isVideo(\SplFileInfo $file)
 {
     if ($file->isDir()) {
         return false;
     }
     $ext = strtolower($file->getExtension());
     $videos = explode(',', 'wmv,ogg,avi,mpg,divx,flv');
     return in_array($ext, $videos);
 }
开发者ID:lewildcode,项目名称:lwcfilemanager,代码行数:14,代码来源:Icon.php

示例15: ensurePresent

 protected function ensurePresent($baseDir)
 {
     $fileInfo = new \SplFileInfo($baseDir);
     if ($fileInfo->isDir()) {
         return;
     }
     $filePath = $fileInfo->getPathname();
     mkdir($filePath);
 }
开发者ID:helstern,项目名称:nomsky-lib,代码行数:9,代码来源:TestOutput.php


注:本文中的SplFileInfo::isDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。