• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP FileSystem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了FileSystem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: testNewSiteExistsEmptyDir

 public function testNewSiteExistsEmptyDir()
 {
     $fs = new FileSystem();
     $fs->mkdir($this->tmpDir);
     $this->assertFileExists($this->tmpDir);
     $operation = new NewSite($this->templatePath);
     $operation->newSite($this->tmpDir, 'blank');
     $this->assertFileExists($this->tmpDir . '/config.yml');
     $this->assertFileExists($this->tmpDir . '/composer.json');
     $this->assertFileExists($this->tmpDir . '/index.html');
     $this->assertFileExists($this->tmpDir . '/_posts');
     $this->assertFileExists($this->tmpDir . '/_layouts');
 }
开发者ID:pancao,项目名称:Spress,代码行数:13,代码来源:NewSiteTest.php


示例16: testNewSiteExistsEmptyDir

 public function testNewSiteExistsEmptyDir()
 {
     $fs = new FileSystem();
     $fs->mkdir($this->tmpDir);
     $this->assertFileExists($this->tmpDir);
     $app = new Application();
     $app->add(new NewSiteCommand());
     $command = $app->find('new:site');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName(), 'path' => $this->tmpDir]);
     $output = $commandTester->getDisplay();
     $this->assertRegExp('/New site created/', $output);
 }
开发者ID:rptec,项目名称:Spress,代码行数:13,代码来源:NewSiteCommandTest.php


示例17: getJson

 public static function getJson($code, $path = '/', $type = 'arr')
 {
     import('ORG.Net.FileSystem');
     $sys = new FileSystem();
     //main
     $basepath = RUNTIME_PATH . 'Data/Json/' . $path;
     $filename = '/' . $code . '_data.json';
     $json = $sys->getFile($basepath . $filename);
     if ($type == 'obj') {
         return json_decode($json);
     } elseif ($type == 'arr') {
         return json_decode($json, true);
     }
 }
开发者ID:huangchuping,项目名称:bug,代码行数:14,代码来源:AppPublic.class.php


示例18: write

 public function write($path, $data, $mode)
 {
     import('ORG.Net.FileSystem');
     $paths = new FileSystem();
     $paths->root = ITEM;
     $paths->charset = C('CFG_CHARSET');
     //main
     if ($mode == 'conf') {
         if (!is_writeable(ROOT . '/Conf')) {
             return -1;
         }
         $fp = fopen($path, 'wb');
         flock($fp, 3);
         fwrite($fp, "<" . "?php\r\n");
         fwrite($fp, "return array(\r\n");
         //dump($data);
         foreach ($data as $fval) {
             $fval['vals'] = htmlspecialchars_decode($fval['vals']);
             if ($fval['types'] == 'int' || $fval['types'] == 'bool') {
                 if ($fval['vals'] == "") {
                     $fval['vals'] = 0;
                 }
                 fwrite($fp, "\t'" . $fval['keyword'] . "' => " . addslashes($fval['vals']) . ",\r\n");
             } elseif ($fval['types'] == 'select' || $fval['types'] == 'more') {
                 list($key, $val) = explode('>>', $fval['vals']);
                 if ($key == 'none') {
                     fwrite($fp, "\t'" . $fval['keyword'] . "' => '',\r\n");
                 } else {
                     fwrite($fp, "\t'" . $fval['keyword'] . "' => '" . addslashes($key) . "',\r\n");
                 }
             } else {
                 fwrite($fp, "\t'" . $fval['keyword'] . "' => '" . addslashes($fval['vals']) . "',\r\n");
             }
         }
         fwrite($fp, ");");
         fclose($fp);
         return 1;
     } elseif ($mode && $mode != 'conf') {
         if (!file_exists($path)) {
             $paths->putDir($path);
         }
         if (!is_writeable($path)) {
             return -1;
         }
         $put = $paths->putFile($path . '/' . $mode . '.json', $data);
         return $put;
     } else {
         $this->error('未知操作模式,请检查!');
     }
 }
开发者ID:huangchuping,项目名称:bug,代码行数:50,代码来源:WritePublic.class.php


示例19: setSystemCrontab

 protected function setSystemCrontab(OutputInterface $output, $newContents)
 {
     $tempCronFileName = '/tmp/madrak_io_easy_cron_deployment.cron.' . time();
     $filesystem = new FileSystem();
     $filesystem->dumpFile($tempCronFileName, $newContents);
     $process = new Process('crontab ' . $tempCronFileName);
     try {
         $process->mustRun();
         return $process->getOutput();
     } catch (ProcessFailedException $e) {
         $this->outputFormattedBlock($output, ['Error!', 'There was an error while attempting to overwrite the existing crontab list.', $e->getMessage()], 'error');
         exit;
     }
 }
开发者ID:MadrakIO,项目名称:easy-cron-deployment-bundle,代码行数:14,代码来源:AbstractCronCommand.php


示例20: testGetFile

 public function testGetFile()
 {
     $fs = new SymfonyFileSystem();
     $someJunk = 'whatever dude';
     $hash = md5($someJunk);
     $testFilePath = $this->uploadDirectory . '/' . $hash;
     file_put_contents($testFilePath, $someJunk);
     $file = m::mock('Symfony\\Component\\HttpFoundation\\File\\File')->shouldReceive('getPathname')->andReturn($testFilePath)->getMock();
     $this->mockFileSystem->shouldReceive('exists')->with($testFilePath)->andReturn(true);
     $this->mockFileSystem->shouldReceive('move');
     $newHash = $this->tempFileSystem->storeFile($file, false);
     $newFile = $this->tempFileSystem->getFile($newHash);
     $this->assertSame($hash, $newHash);
     $this->assertSame(file_get_contents($newFile->getPathname()), $someJunk);
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:15,代码来源:TemporaryFileSystemTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP FileTemplate类代码示例发布时间:2022-05-23
下一篇:
PHP FileSyncPeer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap