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


PHP SplFileInfo::isWritable方法代码示例

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


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

示例1: render

 public function render($view = null, $layout = null)
 {
     try {
         ob_start();
         if (defined('DOMPDF_TEMP_DIR')) {
             $dir = new SplFileInfo(DOMPDF_TEMP_DIR);
             if (!$dir->isDir() || !$dir->isWritable()) {
                 trigger_error(__('%s is not writable', DOMPDF_TEMP_DIR), E_USER_WARNING);
             }
         }
         $errors = ob_get_contents();
         ob_end_clean();
         $download = false;
         $name = pathinfo($this->here, PATHINFO_BASENAME);
         $paperOrientation = 'portrait';
         $paperSize = 'letter';
         extract($this->viewVars, EXTR_IF_EXISTS);
         $dompdf = new DOMPDF();
         $dompdf->load_html($errors . parent::render($view, $layout), Configure::read('App.encoding'));
         $dompdf->set_protocol('');
         $dompdf->set_protocol(WWW_ROOT);
         $dompdf->set_base_path('/');
         $dompdf->set_paper($paperSize, $paperOrientation);
         $dompdf->render();
         $dompdf->stream($name, array('Attachment' => $download));
     } catch (Exception $e) {
         $this->request->params['ext'] = 'html';
         throw $e;
     }
 }
开发者ID:raunakbinani,项目名称:cakephp-dompdf-view,代码行数:30,代码来源:PdfView.php

示例2: upload

 /**
  * Upload (move to target dir) given file
  * @param string $filename
  * @param string $content
  * @return string path to filename
  */
 public function upload($filename, $content)
 {
     if (false === $this->uploadDir->isDir()) {
         try {
             $this->fs->mkdir($this->uploadDir->getPathname());
         } catch (\Exception $e) {
             throw new \RuntimeException('Upload directory is not writable, doesn\'t exist or no space left on the disk.');
         }
     }
     if (false === $this->uploadDir->isWritable()) {
         throw new \RuntimeException('Upload directory is not writable, doesn\'t exist or no space left on the disk.');
     }
     $this->fs->dumpFile($this->uploadDir->getRealPath() . '/' . $filename, $content);
     return $this->uploadDir->getRealPath() . '/' . $filename;
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:21,代码来源:LocalFileStorageService.php

示例3: __construct

 /**
  * Constructs the file cache driver
  *
  * [!!] Note: This method cannot be invoked externally.
  *
  * The file cache driver must be instantiated using the `Cache::instance()` method.
  *
  * @param   array  $config  Config for file cache driver
  *
  * @throws  Cache_Exception
  */
 protected function __construct(array $config)
 {
     // Setup parent
     parent::__construct($config);
     $directory = Arr::get($this->_config, 'cache_dir', Kohana::$cache_dir);
     try {
         $this->_cache_dir = new SplFileInfo($directory);
     } catch (ErrorException $e) {
         $this->_cache_dir = $this->_make_directory($directory, 0777, TRUE);
     } catch (UnexpectedValueException $e) {
         $this->_cache_dir = $this->_make_directory($directory, 0777, TRUE);
     }
     // If the defined directory is a file, get outta here
     if ($this->_cache_dir->isFile()) {
         throw new Cache_Exception('Unable to create cache directory as a file already exists : :resource', array(':resource' => $this->_cache_dir->getRealPath()));
     }
     // Check the read status of the directory
     if (!$this->_cache_dir->isReadable()) {
         throw new Cache_Exception('Unable to read from the cache directory :resource', array(':resource' => $this->_cache_dir->getRealPath()));
     }
     // Check the write status of the directory
     if (!$this->_cache_dir->isWritable()) {
         throw new Cache_Exception('Unable to write to the cache directory :resource', array(':resource' => $this->_cache_dir->getRealPath()));
     }
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:36,代码来源:file.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configHelper = $this->getHelper('configuration');
     /* @var $configHelper GlobalConfigurationHelper */
     $questionHelper = $this->getHelper('question');
     /* @var $questionHelper QuestionHelper */
     $sshConfig = new \SplFileInfo($configHelper->getConfiguration()->getSshDirectory() . '/config');
     if (!$sshConfig->isFile()) {
         throw new NotAFileException($sshConfig);
     }
     if (!$sshConfig->isReadable()) {
         throw new UnreadableFileException($sshConfig);
     }
     if (!$sshConfig->isWritable()) {
         throw new UnwritableFileException($sshConfig);
     }
     $sshConfigLines = file($sshConfig->getPathname());
     $repoName = $input->getArgument('repository');
     $repositoryConfig = $configHelper->getConfiguration()->getRepositoryConfiguration($repoName);
     if (!$questionHelper->ask($input, $output, new ConfirmationQuestion(sprintf('Are you sure you want to remove the ssh key for "%s"? This action is irreversible.', $repoName)))) {
         return 1;
     }
     $sshKeyFile = $repositoryConfig->getIdentityFile();
     $this->unlinkFile($output, $sshKeyFile);
     $this->unlinkFile($output, $sshKeyFile . '.pub');
     if (Util::removeSshAliasLines($sshConfigLines, $repositoryConfig)) {
         $output->writeln(sprintf('Removed section <info>Host %s</info> from <info>%s</info>', $repositoryConfig->getSshAlias(), $sshConfig->getPathname()), OutputInterface::VERBOSITY_VERBOSE);
     }
     $output->writeln(sprintf('Removed repository <info>%s</info>', $repoName));
     $configHelper->getConfiguration()->removeRepositoryConfiguration($repoName);
     FsUtil::file_put_contents($sshConfig->getPathname(), implode('', $sshConfigLines));
     $configHelper->getConfiguration()->write();
     return 0;
 }
开发者ID:vierbergenlars,项目名称:clic,代码行数:34,代码来源:RemoveCommand.php

示例5: upload

 /**
  * Upload an image to local server then return new image path after upload success
  * 
  * @param array $file [tmp_name, name, error, type, size] 
  * @param string image path for saving (this may constain filename)
  * @param string image filename for saving
  * @return string Image path after uploaded
  * @throws Exception If upload failed
  */
 public function upload($file, $newImagePath = '.', $newImageName = NULL)
 {
     if (!empty($file['error'])) {
         $this->_throwException(':method: Upload error. Number: :number', array(':method' => __METHOD__, ':number' => $file['error']));
     }
     if (getimagesize($file['tmp_name']) === FALSE) {
         $this->_throwException(':method: The file is not an image file.', array(':method' => __METHOD__));
     }
     $fileInfo = new \SplFileInfo($newImagePath);
     if (!$fileInfo->getRealPath() or !$fileInfo->isDir()) {
         $this->_throwException(':method: The ":dir" must be a directory.', array(':method' => __METHOD__, ':dir' => $newImagePath));
     }
     $defaultExtension = '.jpg';
     if (empty($newImageName)) {
         if (!in_array($fileInfo->getBasename(), array('.', '..')) and $fileInfo->getExtension()) {
             $newImageName = $fileInfo->getBasename();
         } else {
             $newImageName = uniqid() . $defaultExtension;
         }
     }
     if (!$fileInfo->isWritable()) {
         $this->_throwException(':method: Directory ":dir" is not writeable.', array(':method' => __METHOD__, ':dir' => $fileInfo->getRealPath()));
     }
     $destination = $fileInfo->getRealPath() . DIRECTORY_SEPARATOR . $newImageName;
     if (move_uploaded_file($file['tmp_name'], $destination)) {
         return $destination;
     } else {
         $this->_throwException(':method: Cannot move uploaded file to :path', array(':method' => __METHOD__, ':path' => $fileInfo->getRealPath()));
     }
 }
开发者ID:0hyeah,项目名称:yurivn,代码行数:39,代码来源:Local.php

示例6: createDirectory

/**
 * Recursively create a directory if allowed.
 *
 * @param string $path     The path to the directory which will be created.
 * @param int $permissions The Unix permissions to set on the directory. Ignored
 *                         on Windows machines.
 *
 * @return void
 *
 * @throws \LogicException           if the directory already exists.
 * @throws \UnexpectedValueException if the first existing parent directory in
 *                                   the $path argument is not readable or
 *                                   writable by the user running PHP.
 * @throws \UnexpectedValueException when a recursive call to mkdir() with the
 *                                   given $path and $permissions arguments
 *                                   fails.
 */
function createDirectory($path, $permissions = 0755)
{
    if (is_dir($path)) {
        throw new \LogicException('De map "' . $path . '" bestaat al.', 2);
    }
    // Find the first parent directory and check its permissions.
    $permission = false;
    $parentPath = $path;
    do {
        $parentPath = explode(DIRECTORY_SEPARATOR, trim($parentPath, DIRECTORY_SEPARATOR));
        $parentPathCount = count($parentPath);
        unset($parentPath[--$parentPathCount]);
        $parentPath = implode(DIRECTORY_SEPARATOR, $parentPath);
        // Don't prepend the path with a directory separator on Windows.
        // The drive letter, for example: "C:\", is enough.
        if (PHP_OS !== 'Windows') {
            $parentPath = DIRECTORY_SEPARATOR . $parentPath;
        }
        if (file_exists($parentPath)) {
            $fileInfo = new \SplFileInfo($parentPath);
            if ($fileInfo->isReadable() && $fileInfo->isWritable()) {
                $permission = true;
                break;
            }
        }
    } while ($parentPathCount > 1);
    if ($permission) {
        if (!mkdir($path, $permissions, true)) {
            throw new \UnexpectedValueException('De map "' . $path . '" kon niet aangemaakt worden.', 8);
        }
    } else {
        throw new \UnexpectedValueException('De eerstvolgende bestaande map die boven "' . $path . '" ligt ' . 'is niet lees- of schrijfbaar.', 4);
    }
}
开发者ID:BitmanNL,项目名称:traffictower-cms,代码行数:51,代码来源:createDirectory.php

示例7: __construct

 public function __construct($filename, $dir)
 {
     $info = new \SplFileInfo($dir);
     if (!$info->isDir()) {
         throw new InvalidArgumentException(sprintf('Selection file parent dir not found'));
     }
     if (!$info->isReadable()) {
         throw new InvalidArgumentException(sprintf('Selection file parent dir not readable'));
     }
     if (!$info->isWritable()) {
         throw new InvalidArgumentException(sprintf('Selection file parent dir not writable'));
     }
     $this->file = sprintf('%s/%s', $dir, $filename);
 }
开发者ID:kompakt,项目名称:mediameister,代码行数:14,代码来源:File.php

示例8: __construct

 public function __construct($dir)
 {
     $info = new \SplFileInfo($dir);
     if (!$info->isDir()) {
         throw new InvalidArgumentException(sprintf('Dir not found'));
     }
     if (!$info->isReadable()) {
         throw new InvalidArgumentException(sprintf('Dir not readable'));
     }
     if (!$info->isWritable()) {
         throw new InvalidArgumentException(sprintf('Dir not writable'));
     }
     $this->dir = $dir;
 }
开发者ID:kompakt,项目名称:mediameister,代码行数:14,代码来源:ChildFileNamer.php

示例9: init

 /**
  * init class instance by validating cache directory for being readable and writable
  *
  * @error 16202
  * @return void
  * @throws Xapp_Cache_Driver_Exception
  */
 protected function init()
 {
     try {
         $dir = new SplFileInfo(xapp_get_option(self::PATH, $this));
         if (!$dir->isReadable()) {
             throw new Xapp_Cache_Driver_Exception(_("cache directory is not readable"), 1620201);
         }
         if (!$dir->isWritable()) {
             throw new Xapp_Cache_Driver_Exception(_("cache directory is not writable"), 1620202);
         }
         xapp_set_option(self::PATH, rtrim($dir->getRealPath(), DS) . DS, $this);
     } catch (Exception $e) {
         throw new Xapp_Cache_Driver_Exception(xapp_sprintf(_("cache directory file info error: %d, %s"), $e->getCode(), $e->getMessage()), 1620203);
     }
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:22,代码来源:Php.php

示例10: __construct

 public function __construct(BatchFactoryInterface $batchFactory, DirectoryFactory $directoryFactory, $dir)
 {
     $info = new \SplFileInfo($dir);
     if (!$info->isDir()) {
         throw new InvalidArgumentException(sprintf('Drop dir not found'));
     }
     if (!$info->isReadable()) {
         throw new InvalidArgumentException(sprintf('Drop dir not readable'));
     }
     if (!$info->isWritable()) {
         throw new InvalidArgumentException(sprintf('Drop dir not writable'));
     }
     $this->batchFactory = $batchFactory;
     $this->directoryFactory = $directoryFactory;
     $this->dir = $dir;
 }
开发者ID:kompakt,项目名称:mediameister,代码行数:16,代码来源:DropDir.php

示例11: write

 public function write($data, $file)
 {
     $info = new \SplFileInfo(dirname($file));
     if (!$info->isDir()) {
         throw new InvalidArgumentException(sprintf('File dir not found'));
     }
     if (!$info->isWritable()) {
         throw new InvalidArgumentException(sprintf('File dir not writable'));
     }
     $fileInfo = new \SplFileInfo($file);
     if ($fileInfo->isFile()) {
         unlink($file);
     }
     $h = fopen($file, 'w');
     fwrite($h, $data);
     fclose($h);
 }
开发者ID:kompakt,项目名称:b3d,代码行数:17,代码来源:Writer.php

示例12: render

 public function render($view = null, $layout = null)
 {
     try {
         ob_start();
         if (defined('DOMPDF_TEMP_DIR')) {
             $dir = new SplFileInfo(DOMPDF_TEMP_DIR);
             if (!$dir->isDir() || !$dir->isWritable()) {
                 trigger_error(__('%s is not writable', DOMPDF_TEMP_DIR), E_USER_WARNING);
             }
         }
         $errors = ob_get_contents();
         ob_end_clean();
         $download = false;
         $name = pathinfo($this->here, PATHINFO_BASENAME);
         $paperOrientation = 'portrait';
         $paperSize = 'letter';
         $preData = null;
         $postData = null;
         extract($this->viewVars, EXTR_IF_EXISTS);
         $dompdf = new DOMPDF();
         $dompdf->set_protocol('');
         $dompdf->set_protocol(WWW_ROOT);
         $dompdf->set_base_path('/');
         $dompdf->set_paper($paperSize, $paperOrientation);
         if (!empty($preData) || !empty($postData)) {
             App::import('Vendor', 'Dompdf.PDFMerger', true, array(), 'PDFMerger' . DS . 'PDFMerger.php');
             $merger = new PDFMerger();
             if (!empty($preData)) {
                 $merger->addPdfData($preData, DOMPDF_TEMP_DIR);
             }
             //Get the static information sheet
             $merger->addPdfData(file_get_contents("../View/Courses/survey_explanation.pdf"), DOMPDF_TEMP_DIR);
             if (!empty($postData)) {
                 $merger->addPdfData($postData, DOMPDF_TEMP_DIR);
             }
             $merger->merge($download ? 'download' : 'browser');
         } else {
             $dompdf->stream($name, array('Attachment' => $download));
         }
     } catch (Exception $e) {
         $this->request->params['ext'] = 'html';
         throw $e;
     }
 }
开发者ID:byu-oit-appdev,项目名称:student-ratings,代码行数:44,代码来源:PdfView.php

示例13: createOutFile

 public function createOutFile(File $response)
 {
     $filename = $response->getFilename();
     if ($filename == null) {
         throw new CurlFileException('The target filename of the response is null');
     }
     $outFileInfo = new \SplFileInfo($filename);
     $parentDir = new \SplFileInfo($outFileInfo->getPath());
     if (!$parentDir->isDir()) {
         throw new CurlFileException('The target filename directory does not exist');
     }
     if (!$parentDir->isWritable()) {
         throw new CurlFileException('The target filename directory is not writable');
     }
     if ($outFileInfo->isFile() && !$outFileInfo->isWritable()) {
         throw new CurlFileException('The target filename is not writable');
     }
     $this->fileHandle = \fopen($response->getFilename(), 'w+');
 }
开发者ID:versionable,项目名称:prospect,代码行数:19,代码来源:CurlFile.php

示例14: __construct

 public function __construct(LayoutFactoryInterface $layoutFactory, MetadataWriterFactoryInterface $metadataWriterFactory, MetadataLoaderFactoryInterface $metadataLoaderFactory, ArtworkLocatorFactoryInterface $artworkLocatorFactory, AudioLocatorFactoryInterface $audioLocatorFactory, $dir)
 {
     $info = new \SplFileInfo($dir);
     if (!$info->isDir()) {
         throw new InvalidArgumentException(sprintf('Packshot dir not found'));
     }
     if (!$info->isReadable()) {
         throw new InvalidArgumentException(sprintf('Packshot dir not readable'));
     }
     if (!$info->isWritable()) {
         throw new InvalidArgumentException(sprintf('Packshot dir not writable'));
     }
     $this->metadataWriterFactory = $metadataWriterFactory;
     $this->metadataLoaderFactory = $metadataLoaderFactory;
     $this->artworkLocatorFactory = $artworkLocatorFactory;
     $this->audioLocatorFactory = $audioLocatorFactory;
     $this->dir = $dir;
     $this->name = basename($dir);
     $this->layout = $layoutFactory->getInstance($dir);
 }
开发者ID:kompakt,项目名称:mediameister,代码行数:20,代码来源:Packshot.php

示例15: getCmd

 public function getCmd($inFile, $outFile)
 {
     $info = new \SplFileInfo($inFile);
     if (!$info->isFile()) {
         throw new InvalidArgumentException(sprintf('Audio file not found: %s', $inFile));
     }
     if (!$info->isReadable()) {
         throw new InvalidArgumentException(sprintf('Audio file not readable: %s', $inFile));
     }
     $info = new \SplFileInfo(dirname($outFile));
     if (!$info->isDir()) {
         throw new InvalidArgumentException(sprintf('Output file dir not found: %s', dirname($outFile)));
     }
     if (!$info->isWritable()) {
         throw new InvalidArgumentException(sprintf('Output file dir not writable: %s', dirname($outFile)));
     }
     $cmd = '';
     if ($this->preset !== null) {
         $cmd = sprintf("%s --preset %s", $cmd, $this->preset);
     }
     return sprintf("%s '%s' '%s'", $cmd, $inFile, $outFile);
 }
开发者ID:kompakt,项目名称:audio-tools,代码行数:22,代码来源:LameHelper.php


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