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


PHP SplFileInfo::isDir方法代码示例

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


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

示例1: treatFile

 /**
  * treatFile
  *
  * @param File $file
  * @param bool $recursive
  * @access private
  * @return File
  */
 private function treatFile(SplFileInfo $file)
 {
     if ($file->isDir()) {
         return $this->fileTransformer->transformToDirectory($file);
     } elseif ($file->isFile()) {
         return $this->fileTransformer->transformToFile($file);
     }
 }
开发者ID:opium,项目名称:opium,代码行数:16,代码来源:PhotoFinder.php

示例2: prepareFile

 protected function prepareFile(SplFileInfo $file)
 {
     $filePath = $file->getRelativePathname();
     if ($file->isDir()) {
         $this->newConfig['folders'][] = $filePath;
         return;
     }
     $fileContents = file_get_contents($file->getRealPath());
     $this->newConfig['files'][$filePath] = $fileContents;
 }
开发者ID:revati,项目名称:packager,代码行数:10,代码来源:MakeTemplateConfigCommand.php

示例3: deleteFolderAction

 /**
  * @Route("/file_manager/delete-folder", name="spliced_cms_admin_file_manager_delete_folder")
  * @Template()
  */
 public function deleteFolderAction()
 {
     $this->loadContext();
     if (!$this->dir instanceof \SplFileInfo || !$this->dir->getRealPath() || !$this->file->isDir()) {
         $this->get('session')->getFlashBag()->add('error', 'Directory Not Found');
         return $this->redirect($this->generateUrl('spliced_cms_admin_file_manager', array('dir' => $this->dir->getRelativePath())));
     }
     $fs = new Filesystem();
     $success = false;
     try {
         $fs->remove($this->dir->getRealPath());
         $this->get('session')->getFlashBag()->add('success', 'File Deleted');
         $success = true;
     } catch (\IOException $e) {
         $this->get('session')->getFlashBag()->add('error', 'Could Not Delete Folder');
     }
     return $this->redirect($this->generateUrl('spliced_cms_admin_file_manager', array('dir' => $success ? $this->baseDir->getRelativePath() : $this->dir->getRelativePath())));
 }
开发者ID:splicedmedia,项目名称:cms-bundle,代码行数:22,代码来源:FileManagementController.php

示例4: build

 /**
  * Build the site
  */
 public function build()
 {
     $that = $this;
     $this->root = realpath($this->root);
     // First, clean up non-existent files
     if (file_exists($this->outputDir)) {
         $deleteFinder = new Finder();
         $deleteFinder->in($this->outputDir)->filter(function (SplFileInfo $dstFile) {
             // Filter out entries where the source does not exist, or is not the same type
             $srcFile = new SplFileInfo("{$this->root}/{$dstFile->getRelativePathname()}", $dstFile->getRelativePath(), $dstFile->getRelativePathname());
             $old = $dstFile->isDir() && !$srcFile->isDir() || $dstFile->isFile() && !$srcFile->isFile();
             $event = new OldFileEvent($this, $srcFile, $dstFile, $old);
             $this->dispatcher->dispatch(BrancherEvents::OLDFILE, $event);
             return $event->isOld();
         });
         $this->filesystem->remove($deleteFinder);
     }
     // Find all files in root directory
     $renderFinder = new Finder();
     $renderFinder->files()->in(realpath($this->root))->ignoreDotFiles(false);
     array_map([$renderFinder, 'notPath'], array_filter(array_map(function ($exclude) use($that) {
         return $this->filesystem->makePathRelative(realpath($exclude), $that->root);
     }, array_merge($this->excludes, [$this->outputDir]))));
     $this->dispatcher->dispatch(BrancherEvents::SETUP, new SetupEvent($this, $renderFinder));
     // Render every file and dump to output
     $directoryVisited = [];
     /** @var \Symfony\Component\Finder\SplFileInfo $fileInfo */
     foreach ($renderFinder as $fileInfo) {
         $path = $fileInfo->getRelativePath();
         if (!isset($directoryVisited[$path])) {
             $pathObj = new SplFileInfo($fileInfo->getPath(), basename($fileInfo->getRelativePath()), $fileInfo->getRelativePath());
             $event = new DirectoryEnterEvent($this, $pathObj, $this->getSpecialConfig($fileInfo->getPath()));
             $this->dispatcher->dispatch(BrancherEvents::DIRECTORY_ENTER, $event);
             $directoryVisited[$path] = !$event->isShouldSkip();
         }
         if ($directoryVisited[$fileInfo->getRelativePath()] === false) {
             continue;
         }
         if ($fileInfo->getFilename() === $this->specialFile) {
             continue;
         }
         if (substr($this->finfo->file($fileInfo->getPathname()), 0, 4) === 'text') {
             $this->renderFile($fileInfo->getRelativePathname(), $fileInfo->getRelativePathname(), ['path' => $fileInfo->getRelativePathname()]);
         } else {
             // Dump binary files verbatim into output directory
             $this->filesystem->copy($fileInfo->getPathname(), "{$this->outputDir}/{$fileInfo->getRelativePathname()}");
         }
     }
     // Finally, we need to add all remaining templates as resources to Assetic
     // so it will dump the proper files
     /** @var \Twig_Loader_Filesystem $loader */
     $loader = $this->twig->getLoader();
     if ($loader instanceof \Twig_Loader_Filesystem) {
         $resourceFinder = new Finder();
         foreach ($loader->getNamespaces() as $ns) {
             $resourceFinder->in($loader->getPaths($ns));
         }
         /** @var \Symfony\Component\Finder\SplFileInfo $template */
         foreach ($resourceFinder as $template) {
             $this->manager->addResource(new TwigResource($loader, $template->getRelativePathname()), 'twig');
         }
     }
     $this->writer->writeManagerAssets($this->manager);
     $this->dispatcher->dispatch(BrancherEvents::TEARDOWN, new TeardownEvent($this));
 }
开发者ID:castlepointanime,项目名称:brancher,代码行数:68,代码来源:Brancher.php

示例5: moveFile

 /**
  * Move a single file or folder.
  *
  * @param SplFileInfo $file      The file to move.
  *
  * @param string      $targetDir The destination directory.
  *
  * @param bool        $logging   Flag determining if actions shall get logged.
  *
  * @param IOInterface $ioHandler The io handler to log to.
  *
  * @return void
  *
  * @throws \RuntimeException When an unknown file type has been encountered.
  */
 private function moveFile(SplFileInfo $file, $targetDir, $logging, $ioHandler)
 {
     $pathName = $file->getPathname();
     $destinationFile = str_replace($this->tempDir, $targetDir, $pathName);
     // Symlink must(!) be handled first as the isDir() and isFile() checks return true for symlinks.
     if ($file->isLink()) {
         $target = $file->getLinkTarget();
         if ($logging) {
             $ioHandler->write(sprintf('link %s to %s', $target, $destinationFile));
         }
         symlink($target, $destinationFile);
         unlink($pathName);
         return;
     }
     if ($file->isDir()) {
         $permissions = substr(decoct(fileperms($pathName)), 1);
         $this->folders[] = $pathName;
         if (!is_dir($destinationFile)) {
             if ($logging) {
                 $ioHandler->write(sprintf('mkdir %s (permissions: %s)', $pathName, $permissions));
             }
             mkdir($destinationFile, octdec($permissions), true);
         }
         return;
     }
     if ($file->isFile()) {
         $permissions = substr(decoct(fileperms($pathName)), 1);
         if ($logging) {
             $ioHandler->write(sprintf('move %s to %s (permissions: %s)', $pathName, $destinationFile, $permissions));
         }
         copy($pathName, $destinationFile);
         chmod($destinationFile, octdec($permissions));
         unlink($pathName);
         return;
     }
     throw new \RuntimeException(sprintf('Unknown file of type %s encountered for %s', filetype($pathName), $pathName));
 }
开发者ID:tenside,项目名称:core,代码行数:52,代码来源:InstallTask.php

示例6: processFile

 /**
  * Processes a single file
  *
  * @param SplFileInfo $file            The path to the file
  * @param bool        $replaceExisting True to replace existing license header
  * @param bool        $dryRun          True to report a modified file and to not make modifications
  */
 private function processFile(SplFileInfo $file, $replaceExisting, $dryRun)
 {
     if ($file->isDir()) {
         return;
     }
     $tokens = token_get_all($file->getContents());
     $licenseTokenIndex = $this->getLicenseTokenIndex($tokens);
     if (null !== $licenseTokenIndex && true === $replaceExisting) {
         $this->removeExistingLicense($file, $tokens, $licenseTokenIndex, $dryRun);
     }
     if (null === $licenseTokenIndex || true === $replaceExisting) {
         $this->log(sprintf('<fg=green>[+]</> Adding license header for <options=bold>%s</>', $file->getRealPath()));
         if (true === $dryRun) {
             return;
         }
         $license = $this->getLicenseAsComment();
         $content = preg_replace('/<\\?php/', '<?php' . PHP_EOL . PHP_EOL . $license, $file->getContents(), 1);
         file_put_contents($file->getRealPath(), $content);
     } else {
         $this->log(sprintf('<fg=cyan>[S]</> Skipping <options=bold>%s</>', $file->getRealPath()));
     }
 }
开发者ID:jameshalsall,项目名称:licenser,代码行数:29,代码来源:Licenser.php

示例7: getAllFiles

 /**
  * Lista carpeta y archivos segun el path ingresado, no recursivo, ordenado por tipo y nombre
  * 
  * @param string $path Ruta de la carpeta o archivo
  * @return array|null Listado de archivos o null si no existe
  */
 public function getAllFiles($path)
 {
     $fullpath = $this->getFullPath() . $path;
     if (file_exists($fullpath)) {
         $file = new \SplFileInfo($fullpath);
         if ($file->isDir()) {
             $r = array();
             // if($path != "/") $r[] = $this->folderParent($path);
             $finder = new Finder();
             $directories = $finder->notName('_thumbs')->notName('web.config')->notName('.htaccess')->depth(0)->sortByType();
             // $directories = $directories->files()->name('*.jpg');
             $directories = $directories->in($fullpath);
             foreach ($directories as $key => $directorie) {
                 $namefile = $directorie->getFilename();
                 if ($directorie->isDir() && $this->validNameFile($namefile, false)) {
                     $t = $this->fileInfo($directorie, $path);
                     if ($t) {
                         $r[] = $t;
                     }
                 } elseif ($directorie->isFile() && $this->validNameFile($namefile)) {
                     $t = $this->fileInfo($directorie, $path);
                     if ($t) {
                         $r[] = $t;
                     }
                 }
             }
             return $r;
         } elseif ($file->isFile()) {
             $t = $this->fileInfo($file, $path);
             if ($t) {
                 return $t;
             } else {
                 $result = array("query" => "BE_GETFILEALL_NOT_LEIBLE", "params" => array());
                 $this->setInfo(array("msg" => $result));
                 if ($this->config['debug']) {
                     $this->_log(__METHOD__ . " - Archivo no leible - {$fullpath}");
                 }
                 return;
             }
         } elseif ($file->isLink()) {
             $result = array("query" => "BE_GETFILEALL_NOT_PERMITIDO", "params" => array());
             $this->setInfo(array("msg" => $result));
             if ($this->config['debug']) {
                 $this->_log(__METHOD__ . " - path desconocido - {$fullpath}");
             }
             return;
         }
     } else {
         $result = array("query" => "BE_GETFILEALL_NOT_EXISTED", "params" => array());
         $this->setInfo(array("msg" => $result));
         if ($this->config['debug']) {
             $this->_log(__METHOD__ . " - No existe el archivo - {$fullpath}");
         }
         return;
     }
 }
开发者ID:guillermomartinez,项目名称:filemanager-php,代码行数:62,代码来源:Filemanager.php

示例8: processFile

 /**
  * Processes a single file
  *
  * @param SplFileInfo $file           The path to the file
  * @param boolean     $removeExisting True to remove existing license header before adding new one
  */
 private function processFile(SplFileInfo $file, $removeExisting)
 {
     if ($file->isDir()) {
         return;
     }
     $tokens = token_get_all($file->getContents());
     $licenseTokenIndex = $this->getLicensetokenIndex($tokens);
     if (null !== $licenseTokenIndex && true === $removeExisting) {
         $this->removeExistingLicense($file, $tokens, $licenseTokenIndex);
     }
     if (null === $licenseTokenIndex || true === $removeExisting) {
         $this->log(sprintf('Adding license header for "%s"', $file->getRealPath()));
         $license = $this->getLicenseAsComment();
         $content = preg_replace('/<\\?php/', '<?php' . PHP_EOL . PHP_EOL . $license, $file->getContents(), 1);
         file_put_contents($file->getRealPath(), $content);
     } else {
         $this->log(sprintf('Skipping "%s"', $file->getRealPath()));
     }
 }
开发者ID:picturae,项目名称:licenser,代码行数:25,代码来源:Licenser.php

示例9: isDir

 public function isDir()
 {
     return $this->fileInfo->isDir();
 }
开发者ID:phramz,项目名称:doctrine-annotation-scanner,代码行数:4,代码来源:ClassFileInfo.php


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