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


PHP Filesystem::touch方法代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $verbose = $input->getOption('verbose');
     foreach ($this->importerIterator as $importer) {
         if (null === $input->getArgument('source') || $input->getArgument('source') === $importer->getSource()) {
             $this->filesystem->mkdir($importerDir = $this->path . '/' . $importer->getSource());
             foreach ($importer->getLanguages() as $language) {
                 if (null === $input->getArgument('language') || $input->getArgument('language') === $language) {
                     $this->filesystem->mkdir($exporterDir = $importerDir . '/' . $language);
                     $countries = $importer->getCountries($language);
                     if (!is_array($countries)) {
                         continue;
                     }
                     foreach ($this->exporterIterator as $exporter) {
                         if (null === $input->getArgument('format') || $input->getArgument('format') === $exporter->getFormat()) {
                             $file = $exporterDir . '/country.' . $exporter->getFormat();
                             $this->filesystem->touch($file);
                             file_put_contents($file, $exporter->export($countries));
                             if ($verbose) {
                                 $output->write('<info>[file+]</info> ' . $file . PHP_EOL);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:antonioiradukunda,项目名称:kplhosting,代码行数:31,代码来源:Build.php

示例2: createEmptyFile

 /**
  * {@inheritdoc}
  */
 public function createEmptyFile($basePath, $prefix = null, $suffix = null, $extension = null, $maxTry = 65536)
 {
     if (false === is_dir($basePath) || false === is_writeable($basePath)) {
         throw new IOException(sprintf('`%s` should be a writeable directory', $basePath));
     }
     if ($suffix === null && $extension === null) {
         if (false === ($file = @tempnam($basePath, $prefix))) {
             throw new IOException('Unable to generate a temporary filename');
         }
         return $file;
     }
     while ($maxTry > 0) {
         $file = $basePath . DIRECTORY_SEPARATOR . $prefix . base_convert(mt_rand(0x19a100, 0x39aa3ff), 10, 36) . $suffix . ($extension ? '.' . $extension : '');
         if (false === file_exists($file)) {
             try {
                 $this->filesystem->touch($file);
             } catch (SfIOException $e) {
                 throw new IOException('Unable to touch file', $e->getCode(), $e);
             }
             return $file;
         }
         $maxTry--;
     }
     throw new IOException('Unable to generate a temporary filename');
 }
开发者ID:fluxuator,项目名称:Temporary-Filesystem,代码行数:28,代码来源:TemporaryFilesystem.php

示例3: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $verbose = $input->getOption('verbose');
     foreach ($this->importerIterator as $importer) {
         if (null === $input->getArgument('source') || $input->getArgument('source') === $importer->getSource()) {
             $this->filesystem->mkdir($importerDir = sprintf('%s/%s', $this->path, $importer->getSource()));
             foreach ($importer->getLanguages() as $language) {
                 if (null === $input->getArgument('language') || $input->getArgument('language') === $language) {
                     $this->filesystem->mkdir($exporterDir = sprintf('%s/%s', $importerDir, $language));
                     $countries = $importer->getCountries($language);
                     foreach ($this->exporterIterator as $exporter) {
                         if (null === $input->getArgument('format') || $input->getArgument('format') === $exporter->getFormat()) {
                             $file = sprintf('%s/country.%s', $exporterDir, $exporter->getFormat());
                             $this->filesystem->touch($file);
                             file_put_contents($file, $exporter->export($countries));
                             if ($verbose) {
                                 $output->write(sprintf('<info>[file+]</info> %s%s', $file, PHP_EOL));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:raoul2000,项目名称:country-list,代码行数:28,代码来源:Build.php

示例4: set

 /**
  * @param string $request
  * @param string $url
  * @param string $response
  */
 public function set($request, $url, $response)
 {
     if ($expires = $this->getRequestExpires($request)) {
         $filename = $this->getFilename($url);
         $this->fs->dumpFile($filename, $response);
         $this->fs->touch($filename, $expires);
     }
 }
开发者ID:anime-db,项目名称:ani-db-browser-bundle,代码行数:13,代码来源:CacheResponse.php

示例5: setUp

 public function setUp()
 {
     $this->filesystem = new Filesystem();
     $this->basePath = sys_get_temp_dir() . '/aWebRoot';
     $this->existingFile = $this->basePath . '/aCachePrefix/aFilter/existingPath';
     $this->filesystem->mkdir(dirname($this->existingFile));
     $this->filesystem->touch($this->existingFile);
 }
开发者ID:umanit,项目名称:LiipImagineBundle,代码行数:8,代码来源:WebPathResolverTest.php

示例6: createFile

 /**
  * @param string $filename
  */
 public function createFile($filename)
 {
     if ($this->fs->exists($filename)) {
         throw new Exception('File already exist');
     } else {
         $this->fs->touch($filename);
     }
 }
开发者ID:riki343,项目名称:game1,代码行数:11,代码来源:JSONLoader.php

示例7: open

 /**
  * {@inheritdoc}
  */
 public function open($savePath, $sessionName)
 {
     try {
         $this->fs->touch($this->getSessionFileName($sessionName));
         return true;
     } catch (IOException $e) {
         return false;
     }
 }
开发者ID:atiarda,项目名称:bolt,代码行数:12,代码来源:FileHandler.php

示例8: touch

 /**
  * {@inheritdoc}
  */
 public function touch($files, int $time = null, int $atime = null)
 {
     try {
         $this->filesystem->touch($files, $time, $atime);
     } catch (IOException $exception) {
         throw new FilesystemException($exception->getMessage(), $exception->getPath(), $exception);
     } catch (Exception $exception) {
         throw new FilesystemException($exception->getMessage(), null, $exception);
     }
 }
开发者ID:novuso,项目名称:common-bundle,代码行数:13,代码来源:SymfonyFilesystem.php

示例9: testClean

 /**
  * @dataProvider getCleanFiles
  *
  * @param string $expected
  * @param string $filename
  * @param bool $is_dir
  */
 public function testClean($expected, $filename, $is_dir = false)
 {
     if ($is_dir) {
         $this->fs->mkdir($this->root . $filename);
     } else {
         $this->fs->touch($this->root . $filename);
     }
     $file = new SplFileInfo($this->root . $filename, '', '');
     $this->assertEquals($expected, $this->cleaner->clean($file));
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:17,代码来源:FilenameCleanerTest.php

示例10: testDumpMocksTo

 public function testDumpMocksTo()
 {
     $targetPath = $this->createTempDir();
     $this->filesystem->touch($targetPath . DIRECTORY_SEPARATOR . 'badfile');
     $this->responseLogger->dumpMocksTo($targetPath);
     $this->assertTrue(is_file($targetPath . DIRECTORY_SEPARATOR . 'file'));
     $this->assertTrue(is_dir($targetPath . DIRECTORY_SEPARATOR . 'dir'));
     $this->assertTrue(!is_file($targetPath . DIRECTORY_SEPARATOR . 'badfile'));
     $this->filesystem->remove($targetPath);
 }
开发者ID:dunglas,项目名称:MrocaRequestLogBundle,代码行数:10,代码来源:ResponseLoggerTest.php

示例11: getTempFile

 /**
  * Get a temporary file and populate its data
  *
  * Any files created with this function will be destroyed on cleanup/destruction.
  *
  * @param string $data   Data to populate file with
  * @param string $prefix Optional file prefix
  * @return string
  */
 protected function getTempFile($data = null, $prefix = 'img-mngr-')
 {
     $file = tempnam(sys_get_temp_dir(), $prefix);
     if ($data) {
         file_put_contents($file, $data);
     } else {
         $this->filesystem->touch($file);
     }
     $this->temp_files[] = $file;
     return $file;
 }
开发者ID:bravo3,项目名称:image-manager,代码行数:20,代码来源:AbstractFilesystemEncoder.php

示例12: testReadFileNotValid

 public function testReadFileNotValid()
 {
     $filename = $this->directory . DIRECTORY_SEPARATOR . 'not_valid.log';
     $this->fs->touch($filename);
     $this->context->expects($this->once())->method('hasOption')->with($this->equalTo('file'))->will($this->returnValue(true));
     $this->context->expects($this->once())->method('getOption')->will($this->returnValue($filename));
     $this->contextRegistry->expects($this->exactly(3))->method('getByStepExecution')->will($this->returnValue($this->context));
     $this->reader->setStepExecution($this->stepExecution);
     $this->assertNull($this->reader->read());
     $this->assertNull($this->reader->read());
 }
开发者ID:Maksold,项目名称:platform,代码行数:11,代码来源:LogReaderTest.php

示例13: testApplyDoesNotOverwriteExisting

 /**
  * @covers Kunstmaan\MediaBundle\Helper\Transformer\PdfTransformer::apply
  */
 public function testApplyDoesNotOverwriteExisting()
 {
     $pdfFilename = $this->tempDir . '/sample.pdf';
     $jpgFilename = $pdfFilename . '.jpg';
     $pdf = $this->filesDir . '/sample.pdf';
     $this->filesystem->copy($pdf, $pdfFilename);
     $this->assertTrue(file_exists($pdfFilename));
     $this->filesystem->touch($jpgFilename);
     $transformer = new PdfTransformer(new \Imagick());
     $absolutePath = $transformer->apply($pdfFilename);
     $this->assertEquals($jpgFilename, $absolutePath);
     $this->assertEmpty(file_get_contents($jpgFilename));
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:16,代码来源:PdfTransformerTest.php

示例14: getArgs

 /**
  * @return array
  */
 public function getArgs()
 {
     $this->filesystem->mkdir($this->getTemporaryPath());
     $fileCount = rand(2, 10);
     $realFiles = rand(1, $fileCount - 1);
     $files = [];
     foreach (range(1, $fileCount) as $index) {
         $file = sprintf('%s/%s.txt', $this->getTemporaryPath(), $this->faker->uuid);
         if ($index <= $realFiles) {
             $this->filesystem->touch($file);
         }
         $files[] = $file;
     }
     return $files;
 }
开发者ID:php-school,项目名称:learn-you-php,代码行数:18,代码来源:ArrayWeGo.php

示例15: fillDirectory

 protected function fillDirectory($number)
 {
     $system = new Filesystem();
     for ($i = 0; $i < $number; $i++) {
         $system->touch(sprintf('%s/%s', $this->tmpDir, uniqid()), time() - $i * 60);
     }
 }
开发者ID:lsv,项目名称:OneupUploaderBundle,代码行数:7,代码来源:ChunkStorageTest.php


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