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


PHP FileSystem::exists方法代码示例

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


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

示例1: getFile

 /**
  * Get a File from a hash
  * @param  [string] $relativePath
  * @return File
  */
 public function getFile($relativePath)
 {
     if ($this->fileSystem->exists($this->getPath($relativePath))) {
         return new File($this->getPath($relativePath));
     }
     return false;
 }
开发者ID:Okami-,项目名称:ilios,代码行数:12,代码来源:IliosFileSystem.php

示例2: deepCopy

 public static function deepCopy($src, $dest, array $patternMatch = null)
 {
     $fileSystem = new FileSystem();
     if (!$fileSystem->exists($src)) {
         return;
     }
     if (!$fileSystem->exists($dest)) {
         $fileSystem->mkdir($dest, 0777);
     }
     $match = false;
     if (!empty($patternMatch) && count($patternMatch) == 2) {
         $match = true;
     }
     $fileCount = 0;
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($src, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $path) {
         if ($match && $patternMatch[0]->{$patternMatch}[1]($path->getPathname())) {
             continue;
         }
         $relativeFile = str_replace($src, '', $path->getPathname());
         $destFile = $dest . $relativeFile;
         if ($path->isDir()) {
             if (!$fileSystem->exists($destFile)) {
                 $fileSystem->mkdir($destFile, 0777);
             }
         } else {
             if (strpos($path->getFilename(), ".") === 0) {
                 continue;
             }
             $fileSystem->copy($path->getPathname(), $destFile, true);
             $fileCount++;
         }
     }
     return $fileCount;
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:34,代码来源:FileUtil.php

示例3: write

 /**
  * Write a file
  *
  * @param string $path The directory to put the file in (in the current destination)
  * @param string $content The file content
  * @param string $filename The file name
  * @param string $extension The file extension
  */
 public function write($path, $content, $extension = 'html', $filename = 'index')
 {
     $directory = sprintf('%s/%s', $this->destination, trim($path, '/'));
     $file = sprintf('%s.%s', $filename, $extension);
     if (!$this->files->exists($directory)) {
         $this->files->mkdir($directory);
     }
     $this->files->dumpFile(sprintf('%s/%s', $directory, $file), $content);
 }
开发者ID:phpillip,项目名称:phpillip,代码行数:17,代码来源:Builder.php

示例4: deleteExistingFile

 public function deleteExistingFile($fileIdWithoutExtension, $fileFullPath)
 {
     $fs = new FileSystem();
     if ($fs->exists($fileFullPath . $fileIdWithoutExtension . '.docx')) {
         unlink($fileFullPath . $fileIdWithoutExtension . '.docx');
     } elseif ($fs->exists($fileFullPath . $fileIdWithoutExtension . '.doc')) {
         unlink($fileFullPath . $fileIdWithoutExtension . '.doc');
     } elseif ($fs->exists($fileFullPath . $fileIdWithoutExtension . '.pdf')) {
         unlink($fileFullPath . $fileIdWithoutExtension . '.pdf');
     }
     return;
 }
开发者ID:souravmondal-cn,项目名称:interviewSystem,代码行数:12,代码来源:FileHandler.php

示例5: load

 public function load()
 {
     if ($this->file === NULL) {
         throw new \Exception(__CLASS__ . ": Missing required property (configFile)");
     }
     if ($this->fs->exists($this->file)) {
         $items = $this->decodeDocument(file_get_contents($this->file));
         $this->instances = array();
         foreach ($items as $key => $item) {
             $this->instances[$key] = $this->decodeItem($item);
         }
     } else {
         $this->instances = array();
     }
 }
开发者ID:eileenmcnaughton,项目名称:amp,代码行数:15,代码来源:FileRepository.php

示例6: downloadFileTaskAction

 /**
  * Serve a file by forcing the download
  *
  * @Route("/download-task/{id}", name="download_file_task", requirements={"filename": ".+"})
  */
 public function downloadFileTaskAction($id)
 {
     /**
      * $basePath can be either exposed (typically inside web/)
      * or "internal"
      */
     $repository = $this->getDoctrine()->getRepository('TrackersBundle:Project_Task_Attachments');
     $files = $repository->find($id);
     if (empty($files)) {
         throw $this->createNotFoundException();
     }
     $filename = $files->getFileurl();
     $basePath = $this->get('kernel')->getRootDir() . '/../web/upload';
     $filePath = $basePath . '/' . $filename;
     $name_array = explode('/', $filename);
     $filename = $name_array[sizeof($name_array) - 1];
     // check if file exists
     $fs = new FileSystem();
     if (!$fs->exists($filePath)) {
         throw $this->createNotFoundException();
     }
     header('Content-Description: File Transfer');
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; filename=' . basename($filePath));
     header('Expires: 0');
     header('Cache-Control: must-revalidate');
     header('Pragma: public');
     header('Content-Length: ' . filesize($filePath));
     readfile($filePath);
     exit;
 }
开发者ID:niceit,项目名称:sf-tracker,代码行数:36,代码来源:DownloadController.php

示例7: checkRepositoryExists

 private function checkRepositoryExists($path)
 {
     $fs = new FileSystem();
     if (!$fs->exists($path)) {
         throw new PayrollRepositoryDoesNotExist(sprintf('Path %s does not exist.', $path));
     }
 }
开发者ID:franiglesias,项目名称:milhojas,代码行数:7,代码来源:FileSystemPayrolls.php

示例8: testSavingNamespacedConfig

 public function testSavingNamespacedConfig()
 {
     $group = md5(time() . uniqid());
     $namespace = md5(time() . uniqid());
     $item = 'this.is.the.test.key';
     $value = $group;
     $this->saver->save($item, $value, 'testing', $group, $namespace);
     $path = DIR_APPLICATION . "/config/generated_overrides/{$namespace}/{$group}.php";
     $exists = $this->files->exists($path);
     $array = array();
     if ($exists) {
         $array = $this->files->getRequire($path);
         $this->files->delete($path);
     }
     $this->assertTrue($exists, 'Failed to save file');
     $this->assertEquals($value, array_get($array, $item), 'Failed to save correct value.');
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:17,代码来源:FileSaverTest.php

示例9: getStagingDir

 /**
  * Get the staging directory for processed deposits.
  *
  * @param Journal $journal
  *
  * @return string
  */
 public final function getStagingDir(Journal $journal)
 {
     $path = $this->absolutePath('staged', $journal);
     if (!$this->fs->exists($path)) {
         $this->logger->notice("Creating directory {$path}");
         $this->fs->mkdir($path);
     }
     return $path;
 }
开发者ID:ubermichael,项目名称:pkppln-php,代码行数:16,代码来源:FilePaths.php

示例10: loadConfig

 /**
  * Loads app config from environment source code into $this->config
  */
 private function loadConfig()
 {
     // Look for .director.yml
     $fs = new FileSystem();
     if ($fs->exists($this->getSourcePath() . '/.director.yml')) {
         $this->config = Yaml::parse(file_get_contents($this->getSourcePath() . '/.director.yml'));
     } else {
         $this->config = NULL;
     }
 }
开发者ID:jonpugh,项目名称:director,代码行数:13,代码来源:EnvironmentFactory.php

示例11: frontendAction

 public function frontendAction(Request $request, $path)
 {
     if (strpos($path, 'assets/') === 0) {
         $assetPath = $this->get('kernel')->getRootDir() . '/../web/' . $path;
         $fs = new FileSystem();
         if (!$fs->exists($assetPath)) {
             throw $this->createNotFoundException();
         } else {
             $response = new BinaryFileResponse($assetPath);
             if ((new File($assetPath))->getExtension() === 'html') {
                 $response->headers->set('Content-Type', 'text/html');
             }
             return $response;
         }
     }
     return $this->render('AppBundle:Default:index.html.twig');
 }
开发者ID:Grreg,项目名称:welcome-help-planner,代码行数:17,代码来源:DefaultController.php

示例12: downloadFileAction

 /**
  * Serve a file by forcing the download
  *
  * @Route("/download/{filename}", name="download_file", requirements={"filename": ".+"})
  */
 public function downloadFileAction($filename)
 {
     /**
      * $basePath can be either exposed (typically inside web/)
      * or "internal"
      */
     $basePath = $this->container->getParameter('kernel.root_dir') . '/Resources/uploads';
     $filePath = $basePath . '/' . $filename;
     // check if file exists
     $fs = new FileSystem();
     if (!$fs->exists($filePath)) {
         throw $this->createNotFoundException();
     }
     // prepare BinaryFileResponse
     $response = new BinaryFileResponse($filePath);
     $response->trustXSendfileTypeHeader();
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $filename, iconv('UTF-8', 'ASCII//TRANSLIT', $filename));
     return $response;
 }
开发者ID:Immolare,项目名称:Litige,代码行数:24,代码来源:MediasController.php

示例13: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io = new SymfonyStyle($input, $output);
     $fs = new FileSystem();
     $this->io->title('RCHJWTUserBundle - Generate SSL Keys');
     $rootDir = $this->getContainer()->getParameter('kernel.root_dir');
     $passphrase = $this->getContainer()->getParameter('rch_jwt_user.passphrase');
     $path = $rootDir . '/jwt';
     /* Symfony3 directory structure */
     if (is_writable($rootDir . '/../var')) {
         $path = $rootDir . '/../var/jwt';
     }
     if (!$fs->exists($path)) {
         $fs->mkdir($path);
     }
     $this->generatePrivateKey($path, $passphrase, $this->io);
     $this->generatePublicKey($path, $passphrase, $this->io);
     $outputMessage = 'RSA keys successfully generated';
     if ($passphrase) {
         $outputMessage .= $this->io->getFormatter()->format(sprintf(' with passphrase <comment>%s</comment></info>', $passphrase));
     }
     $this->io->success($outputMessage);
 }
开发者ID:chalasr,项目名称:RCHJWTUserBundle,代码行数:26,代码来源:GenerateKeysCommand.php

示例14: restoreMergedBackupFromRemoteHost

 public function restoreMergedBackupFromRemoteHost($dataItemId, $hostUrl, $sessionId, $fileName)
 {
     // Restore session with session id
     global $SynchSessionController, $SynchServerController;
     $session = $SynchSessionController->createSessionAsCurrent(true, array('id' => $sessionId));
     $session->servers = new stdClass();
     $session->servers->{$SynchServerController->getServerId()} = new stdClass();
     $session->servers->{$SynchServerController->getRemoteServerId()} = new stdClass();
     $this->moveBackupFromQueueToSession($session, $fileName, 0);
     $files = array();
     $files['merged'] = $fileName;
     $sessionBackupPath = $this->createSessionBackupPath($session);
     $path = $sessionBackupPath . '/' . $fileName;
     if (!FileSystem::exists($path, 'f')) {
         return false;
     }
     $remoteServerId = $SynchServerController->getRemoteServerId();
     $this->setSessionHasChangesByServerId(true, $remoteServerId, $session);
     $this->setSessionItemExistsByServerId(array($dataItemId), $SynchServerController->getServerId(), $session);
     return $this->restoreMergedBackup($dataItemId, $files, $session);
 }
开发者ID:r007,项目名称:PMoodle,代码行数:21,代码来源:synch_synch_controller.php

示例15: checkLearningMaterialFilePath

 /**
  * Get if a learning material file path is valid
  * @param LearningMaterialInterface $lm
  *
  * @return boolean
  */
 public function checkLearningMaterialFilePath(LearningMaterialInterface $lm)
 {
     $relativePath = $lm->getRelativePath();
     $fullPath = $this->getPath($relativePath);
     return $this->fileSystem->exists($fullPath);
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:12,代码来源:IliosFileSystem.php


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