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


PHP FileSystem::mkdir方法代码示例

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


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

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

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

示例3: __construct

 public function __construct(SymfonyFileSystem $fs, $kernelRootDirectory)
 {
     $tmpPath = realpath($kernelRootDirectory . '/../var/tmp');
     $this->fileSystem = $fs;
     $this->temporaryFileStorePath = $tmpPath . '/uploads';
     if (!$this->fileSystem->exists($this->temporaryFileStorePath)) {
         $this->fileSystem->mkdir($this->temporaryFileStorePath);
     }
     $this->fileSystem = $fs;
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:10,代码来源:TemporaryFileSystem.php

示例4: createDirectory

 /**
  * @param $path
  * @param $directoryName
  * @return StandardResponseInterface
  */
 public function createDirectory($path, $directoryName)
 {
     if (!$this->isNameValid($directoryName)) {
         return new StandardResponse(false, 'Name not valid. Only a-z, A-Z, 0-9, - and _ are authorized');
     }
     $realPath = $this->getRealPath($path);
     try {
         $this->fs->mkdir($realPath . '/' . $directoryName);
         return new StandardResponse();
     } catch (IOException $e) {
         return new StandardResponse(false, 'Unable to create directory');
     }
 }
开发者ID:tamcy,项目名称:ElendevRoxyFilemanBundle,代码行数:18,代码来源:LocalFileSystem.php

示例5: write

 /**
  * Writes the class to a file.
  */
 public function write()
 {
     try {
         $dir = $this->path->isDir() ? $this->path->getPathname() : $this->path->getPath();
         $path = $dir . '/' . $this->baseClass->getClassName() . $this->baseClass->getExtension();
         if (!file_exists($dir)) {
             $this->fileSystem->mkdir($dir, 0777, true);
         }
         //if (!file_exists($path)) {
         file_put_contents($path, $this->baseClass->generate());
         //}
     } catch (IOExceptionInterface $e) {
     }
 }
开发者ID:jdgriffith,项目名称:ImagineBundle,代码行数:17,代码来源:ClassWriter.php

示例6: storeLearningMaterialFile

 /**
  * Store a learning material file and return the relativePath
  * @param File $file
  * @param boolean $preserveOriginalFile
  * @return string $relativePath
  */
 public function storeLearningMaterialFile(File $file, $preserveOriginalFile = true)
 {
     $relativePath = $this->getLearningMaterialFilePath($file);
     $fullPath = $this->getPath($relativePath);
     $dir = dirname($fullPath);
     $this->fileSystem->mkdir($dir);
     if ($preserveOriginalFile) {
         $this->fileSystem->copy($file->getPathname(), $fullPath, false);
     } else {
         if (!$this->fileSystem->exists($fullPath)) {
             $this->fileSystem->rename($file->getPathname(), $fullPath);
         }
     }
     return $relativePath;
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:21,代码来源:IliosFileSystem.php

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

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

示例9: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $serverDefinition = $container->getDefinition('secotrust.sabredav.server');
     $fileSystem = new FileSystem();
     foreach ($container->findTaggedServiceIds('secotrust.sabredav.plugin') as $id => $attr) {
         $serverDefinition->addMethodCall('addPlugin', array(new Reference($id)));
         switch ($id) {
             case 'secotrust.sabredav_lock_plugin':
                 $definition = $container->getDefinition('secotrust.sabredav_lock_backend');
                 $file = $container->getParameterBag()->resolveValue($definition->getArgument(0));
                 $fileSystem->mkdir(dirname($file));
                 break;
             case 'secotrust.sabredav_temp_plugin':
                 $definition = $container->getDefinition('secotrust.sabredav_temp_plugin');
                 $dir = $container->getParameterBag()->resolveValue($definition->getArgument(0));
                 $fileSystem->mkdir($dir);
                 break;
         }
     }
 }
开发者ID:bartv2,项目名称:SecotrustSabreDavBundle,代码行数:23,代码来源:PluginPass.php

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

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

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

示例13: getTemplateData

 public function getTemplateData(File $file, $refresh = false)
 {
     //from cache
     if (!$refresh) {
         return $this->importData;
     }
     $archive = new \ZipArchive();
     $fileName = $file->getBasename('.zip');
     $extractPath = $this->templateDirectory . DIRECTORY_SEPARATOR . $fileName;
     if ($archive->open($file->getPathname())) {
         $fs = new FileSystem();
         $fs->mkdir($extractPath);
         if (!$archive->extractTo($extractPath)) {
             throw new \Exception("The workspace archive couldn't be extracted");
         }
         $archive->close();
         $resolver = new Resolver($extractPath);
         $this->importData = $resolver->resolve();
         return $this->importData;
     }
     throw new \Exception("The workspace archive couldn't be opened");
 }
开发者ID:claroline,项目名称:distribution,代码行数:22,代码来源:WorkspaceManager.php

示例14: createDirectory

 /**
  * Creates the directory to extract compressed files
  * 
  * Should be removed after completion
  *
  * @param string $month 
  * @return void
  * @author Fran Iglesias
  */
 private function createDirectory($month)
 {
     $fs = new FileSystem();
     $fs->mkdir($this->basePath . '/' . $month);
     return new SpecificDirectory($this->basePath . '/' . $month);
 }
开发者ID:franiglesias,项目名称:milhojas,代码行数:15,代码来源:ZipPayrolls.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $type = $input->getArgument('type');
     if ($type == 'zip' || $type == 'ZIP') {
         $output->writeln('<info>Creating a ZIP package...</info>');
         $output->writeln('<info>Archiving master branch...</info>');
         $archiver = new Process('git archive --format zip --output ' . self::OPERATION_DIRECTORY . self::ZIP_FILE_NAME . ' master ');
         $archiver->run();
         if (!$archiver->isSuccessful()) {
             $output->writeln('<info>Could not archive master branch.</info>');
             $output->writeln('<error>' . $archiver->getErrorOutput() . '</error>');
             return;
         } else {
             $output->writeln('<info>Done!</info>');
             $output->writeln('<info>The archive is at: ' . self::OPERATION_DIRECTORY . self::ZIP_FILE_NAME);
         }
     }
     if ($type == 'deb' || $type == 'DEB') {
         $output->writeln('<info>Creating a Debian package...</info>');
         $filesystem = new FileSystem();
         try {
             $filesystem->mkdir(self::REPO_DIRECTORY);
             $filesystem->mkdir(self::OUTPUT_DIRECTORY);
         } catch (IOExceptionInterface $error) {
             echo "An error occurred while creating your directory at " . $error->getPath();
         }
         $output->writeln('<info>Archiving master branch...</info>');
         $archiver = new Process('git archive master | tar -x -C ' . self::REPO_DIRECTORY);
         $archiver->run();
         if (!$archiver->isSuccessful()) {
             $output->writeln('<info>Could not archive master branch.</info>');
             $output->writeln('<error>' . $archiver->getErrorOutput() . '</error>');
             return;
         }
         $output->writeln('<info>Installing dependencies...</info>');
         $composer = new Process('composer install');
         $composer->setWorkingDirectory(self::REPO_DIRECTORY);
         $composer->setTimeout(3600);
         $composer->run();
         $bower = new Process('bower install');
         $bower->setWorkingDirectory(self::REPO_DIRECTORY);
         $bower->setTimeout(3600);
         $bower->run();
         $dependencies = ['php5', 'php5-mysql', 'php5-mongo', 'php5-mcrypt', 'php5-memcached', 'php5-curl', 'memcached', 'mongodb'];
         $control = new StandardFile();
         $control->setPackageName('ojs')->setProvides('ojs')->setVersion('1.5')->setDepends($dependencies)->setInstalledSize(10240)->setDescription('Open Journal Software')->setMaintainer('Utku Aydın', 'utku.aydin@okulbilisim.com');
         $packager = new Packager();
         $packager->setControl($control);
         $packager->setOutputPath(self::OUTPUT_DIRECTORY);
         $packager->setPostInstallScript($this->getContainer()->get('kernel')->getRootDir() . '/../tools/debian/postinst');
         $packager->setPostRemoveScript($this->getContainer()->get('kernel')->getRootDir() . '/../tools/debian/postrm');
         $packager->addMount(self::REPO_DIRECTORY, '/opt/ojs');
         $packager->run();
         $command = $packager->build(self::DEB_FILE_NAME);
         $output->writeln('<info>Creating a DEB file...</info>');
         $process = new Process($command);
         $process->setWorkingDirectory(self::OPERATION_DIRECTORY);
         $process->setTimeout(3600);
         $process->run();
         if (!$process->isSuccessful()) {
             $output->writeln('<info>Could not create a DEB file.</info>');
             $output->writeln('<error>' . $process->getErrorOutput() . '</error>');
         } else {
             $output->writeln('<info>Done!</info>');
             $output->writeln('<info>The package is at: ' . self::OPERATION_DIRECTORY . self::DEB_FILE_NAME);
         }
     }
 }
开发者ID:necatikartal,项目名称:ojs,代码行数:68,代码来源:PackageCommand.php


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