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


PHP FileSystem类代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln("<error>Be carreful, you might removes files you don't want to. You should backup your files beforehand to be sure everything still works as intended.</error>");
     $force = $input->getOption('force');
     $container = $this->getContainer();
     $fs = new FileSystem();
     $helper = $this->getHelper('question');
     //Parse the file directory and fetch the other directories
     //We should find Workspaces and Users. Workspaces being formatted like "WORKSPACE_[ID]
     $fileDir = $container->getParameter('claroline.param.files_directory');
     $iterator = new \DirectoryIterator($fileDir);
     foreach ($iterator as $pathinfo) {
         if ($pathinfo->isDir()) {
             $name = $pathinfo->getBasename();
             //look for workspaces
             if (strpos('_' . $name, 'WORKSPACE')) {
                 $parts = explode('_', $name);
                 $id = $parts[1];
                 $workspace = $container->get('claroline.manager.workspace_manager')->getWorkspaceById($id);
                 if (!$workspace) {
                     $continue = false;
                     if (!$force) {
                         $question = new ConfirmationQuestion('Do you really want to remove the directory ' . $pathinfo->getPathname() . ' [y/n] y ', true);
                         $continue = $helper->ask($input, $output, $question);
                     }
                     if ($continue || $force) {
                         $fs->remove($pathinfo->getPathname());
                     }
                 }
             }
         }
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:33,代码来源:RemoveFilesFromUnusedWorkspaceCommand.php

示例2: connect

 public function connect(Application $app)
 {
     // creates a new controller based on the default route
     $controllers = $app['controllers_factory'];
     $names = [];
     foreach ($this->faculty->professors as $professor) {
         $names[] = $professor->name;
     }
     $fs = new FileSystem();
     $fs->remove($this->faculty->baseCacheDestination);
     $names = '(' . implode('|', $names) . ')';
     $faculty = $this->faculty;
     $controllers->get('/{processor}/{path}', function (Application $app, $processor, $path) use($faculty) {
         $exten = [];
         preg_match($faculty->extenstions, $path, $exten);
         $exten = ltrim($exten[0], '.');
         if (empty($exten)) {
             return $app->abort(404);
         }
         $faculty->process($processor, $path);
         $imagePath = $faculty->getLastProcessed()[0];
         return $app->sendFile($imagePath, 200, array('Content-Type' => 'image/' . $exten));
     })->assert('path', $this->faculty->extenstions);
     return $controllers;
 }
开发者ID:maciekpaprocki,项目名称:imageprofessor,代码行数:25,代码来源:SilexProvider.php

示例3: 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

示例4: extractTo

 public function extractTo($extractPath, $files = null)
 {
     $fs = new FileSystem();
     $ds = DIRECTORY_SEPARATOR;
     for ($i = 0; $i < $this->numFiles; $i++) {
         $oldName = parent::getNameIndex($i);
         $newName = mb_convert_encoding($this->getNameIndex($i), 'ISO-8859-1', 'CP850,UTF-8');
         //we cheat a little because we can't tell wich name the extracted part should have
         //so we put it a directory wich share it's name
         $tmpDir = $extractPath . $ds . '__claro_zip_hack_' . $oldName;
         parent::extractTo($tmpDir, parent::getNameIndex($i));
         //now we move the content of the directory and we put the good name on it.
         foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
             if ($item->isFile()) {
                 $fs->mkdir(dirname($extractPath . $ds . $oldName));
                 $fs->rename($item->getPathname(), $extractPath . $ds . $oldName);
             }
         }
     }
     //we remove our 'trash here'
     $iterator = new \DirectoryIterator($extractPath);
     foreach ($iterator as $item) {
         if (strpos($item->getFilename(), '_claro_zip_hack')) {
             $fs->rmdir($item->getRealPath(), true);
         }
     }
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:27,代码来源:ZipArchive.php

示例5: 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

示例6: testCleanUp

 public function testCleanUp()
 {
     $fs = new FileSystem();
     $fs->dumpFile($this->tmpDir . '/dummy-file', 'Dummy content.');
     $dw = new FilesystemDataWriter(new Filesystem(), $this->tmpDir);
     $dw->setUp();
     $this->assertFileNotExists($this->tmpDir . '/dummy-file');
 }
开发者ID:spress,项目名称:spress-core,代码行数:8,代码来源:FilesystemDataWriterTest.php

示例7: cleanupClientSpec

 public function cleanupClientSpec()
 {
     $client = $this->getClient();
     $command = 'p4 client -d $client';
     $this->executeCommand($command);
     $clientSpec = $this->getP4ClientSpec();
     $fileSystem = new FileSystem($this->process);
     $fileSystem->remove($clientSpec);
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:9,代码来源:Perforce.php

示例8: main

function main()
{
    if (false === auth()) {
        error("Not logged in", 403);
    }
    $fs = new FileSystem();
    $file = $fs->getOwnFile();
    $fs->delete($file);
}
开发者ID:rxadmin,项目名称:ufoai,代码行数:9,代码来源:cgamedelete.php

示例9: onKernelTerminate

 /**
  * @DI\Observe("kernel.terminate")
  */
 public function onKernelTerminate(PostResponseEvent $event)
 {
     if (count($this->elementsToRemove) > 0) {
         $fs = new FileSystem();
         foreach ($this->elementsToRemove as $element) {
             $fs->remove($element);
         }
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:12,代码来源:KernelTerminateListener.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: savePsr4s

 public static function savePsr4s($vendorDir, $localPsr4Config, $io)
 {
     $filesystem = new FileSystem();
     $psr4File = $filesystem->normalizePath(realpath($vendorDir . self::PSR4_FILE));
     if ($localPsr4Config && $psr4File) {
         $io->write('generating local autoload_psr4.php ....');
         self::appendBeforeLastline($localPsr4Config, $psr4File);
         $io->write('local autoload_psr4 generated.');
     }
 }
开发者ID:jaslin,项目名称:composer-yii2-local-extension-setup-scripts,代码行数:10,代码来源:ComposerScripts.php

示例12: removeModuleFromDisk

 public function removeModuleFromDisk($name)
 {
     $fs = new FileSystem();
     try {
         $fs->remove(_PS_MODULE_DIR_ . '/' . $name);
         return true;
     } catch (IOException $e) {
         return false;
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:10,代码来源:ModuleDataUpdater.php

示例13: ExtractTemplateFileTags

 /**
  * Used to get tags within given template file
  * 
  * It reads a template file and extracts all the tags in the template file
  * 
  * @since 1.0.1 
  * @param string $template_path absolute path to the template html file
  * 
  * @return array $template_information an array with 2 elements.
  * first one is the template contents string.
  * the second one is the template tag replacement string
  */
 function ExtractTemplateFileTags($template_path)
 {
     /** The filesystem object */
     $filesystem_obj = new FileSystem(array());
     $template_contents = $filesystem_obj->ReadLocalFile($template_path);
     /** All template tags of the form {} are extracted from the template file */
     preg_match_all("/\\{(.+)\\}/iU", $template_contents, $matches);
     $template_tag_list = $matches[1];
     $template_information = array($template_contents, $template_tag_list);
     return $template_information;
 }
开发者ID:pluginscart,项目名称:Pak-PHP,代码行数:23,代码来源:Template.php

示例14: 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

示例15: 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


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