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


PHP Util::normalizePath方法代码示例

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


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

示例1: prefix

 /**
  * Prefix a path with the root
  *
  * @param   string  $path
  * @return  string  prefixed path
  */
 protected function prefix($path)
 {
     if (empty($path)) {
         return $this->root;
     }
     $path = str_replace('/', DIRECTORY_SEPARATOR, $path);
     return $this->root . Util::normalizePath($path, DIRECTORY_SEPARATOR);
 }
开发者ID:luoshulin,项目名称:falcon,代码行数:14,代码来源:Local.php

示例2: prefix

 /**
  * Prefix a path with the root
  *
  * @param   string  $path
  * @return  string  prefixed path
  */
 public function prefix($path)
 {
     if ($path === '') {
         return $this->root;
     }
     $path = str_replace('/', DIRECTORY_SEPARATOR, $path);
     return $this->root . Util::normalizePath($path, DIRECTORY_SEPARATOR);
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:14,代码来源:Local.php

示例3: handle

 /**
  * Emulates touch().
  *
  * @param string $path
  *
  * @return bool True on success, false on failure.
  */
 public function handle($path)
 {
     $path = Util::normalizePath($path);
     $adapter = $this->filesystem->getAdapter();
     if ($adapter->has($path)) {
         return true;
     }
     return (bool) $adapter->write($path, '', $this->defaultConfig());
 }
开发者ID:twistor,项目名称:flysystem-stream-wrapper,代码行数:16,代码来源:Touch.php

示例4: getFinder

 /**
  * @param string $path child path to find in
  *
  * @return Finder
  */
 public function getFinder($path = '')
 {
     $path = Util::normalizePath($path);
     $adapter = $this->getAdapter();
     if (!$adapter instanceof FindableAdapterInterface) {
         throw new NotSupportedException("Adapter doesn't support getFinder action. Adapter in use is: " . get_class($adapter));
     }
     return $adapter->getFinder($path);
 }
开发者ID:oasmobile,项目名称:php-flysystem-wrappers,代码行数:14,代码来源:ExtendedFilesystem.php

示例5: handle

 /**
  * Creates a directory.
  *
  * @param string $dirname
  * @param int    $mode
  * @param int    $options
  *
  * @return bool True on success, false on failure.
  */
 public function handle($dirname, $mode, $options)
 {
     $dirname = Util::normalizePath($dirname);
     $adapter = $this->filesystem->getAdapter();
     // If recursive, or a single level directory, just create it.
     if ($options & STREAM_MKDIR_RECURSIVE || strpos($dirname, '/') === false) {
         return (bool) $adapter->createDir($dirname, $this->defaultConfig());
     }
     if (!$adapter->has(dirname($dirname))) {
         throw new FileNotFoundException($dirname);
     }
     return (bool) $adapter->createDir($dirname, $this->defaultConfig());
 }
开发者ID:twistor,项目名称:flysystem-stream-wrapper,代码行数:22,代码来源:Mkdir.php

示例6: handle

 /**
  * Renames a file.
  *
  * @param string $path    path to file
  * @param string $newpath new path
  *
  * @throws \League\Flysystem\FileNotFoundException
  * @throws \Twistor\Flysystem\Exception\DirectoryExistsException
  * @throws \Twistor\Flysystem\Exception\DirectoryNotEmptyException
  * @throws \Twistor\Flysystem\Exception\NotADirectoryException
  *
  * @return bool
  */
 public function handle($path, $newpath)
 {
     $path = Util::normalizePath($path);
     $newpath = Util::normalizePath($newpath);
     // Ignore useless renames.
     if ($path === $newpath) {
         return true;
     }
     if (!$this->isValidRename($path, $newpath)) {
         // Returns false if a Flysystem call fails.
         return false;
     }
     return (bool) $this->filesystem->getAdapter()->rename($path, $newpath);
 }
开发者ID:twistor,项目名称:flysystem-stream-wrapper,代码行数:27,代码来源:ForcedRename.php

示例7: handle

 /**
  * Delete a directory.
  *
  * @param string $dirname path to directory
  * @param int    $options
  *
  * @return bool
  */
 public function handle($dirname, $options)
 {
     $dirname = Util::normalizePath($dirname);
     if ($dirname === '') {
         throw new RootViolationException('Root directories can not be deleted.');
     }
     $adapter = $this->filesystem->getAdapter();
     if ($options & STREAM_MKDIR_RECURSIVE) {
         // I don't know how this gets triggered.
         return (bool) $adapter->deleteDir($dirname);
     }
     $contents = $this->filesystem->listContents($dirname);
     if (!empty($contents)) {
         throw new DirectoryNotEmptyException();
     }
     return (bool) $adapter->deleteDir($dirname);
 }
开发者ID:twistor,项目名称:flysystem-stream-wrapper,代码行数:25,代码来源:Rmdir.php

示例8: onGetClassGenerateFile

 /**
  * Use flysystem to save the file in the desired location.
  *
  * @param \Onema\ClassyFile\Event\GetClassEvent $event
  */
 public function onGetClassGenerateFile(GetClassEvent $event)
 {
     $statement = $event->getStatements();
     $fileLocation = $event->getFileLocation();
     $code = $event->getCode();
     $name = $statement->name;
     if (!$this->filesystem->has($fileLocation)) {
         // dir doesn't exist, make it
         $this->filesystem->createDir($fileLocation);
     }
     $location = sprintf('%s/%s.php', $fileLocation, $name);
     $this->filesystem->put($location, $code);
     $adapter = $this->filesystem->getAdapter();
     if ($adapter instanceof AbstractAdapter) {
         $prefix = $adapter->getPathPrefix();
         $location = Util::normalizePath($location);
         $event->setFileLocation(sprintf('%s%s', $prefix, $location));
     }
 }
开发者ID:onema,项目名称:classyfile,代码行数:24,代码来源:GenerateClassFile.php

示例9: _joinPath

 /**
  * Join dir name and file name and return full path
  *
  * @param  string  $dir
  * @param  string  $name
  * @return string
  * @author Dmitry (dio) Levashov
  **/
 protected function _joinPath($dir, $name)
 {
     return Util::normalizePath($dir . $this->separator . $name);
 }
开发者ID:quepasso,项目名称:dashboard,代码行数:12,代码来源:ElFinderVolumeFlysystem.php

示例10: createFile

 /**
  * @param string $path
  * @param array  $config
  *
  * @throws \LogicException
  * @throws \InvalidArgumentException
  * @throws \Exception|\Throwable
  *
  * @return MediaEntity
  */
 protected function createFile($path, array $config)
 {
     $path = Util::normalizePath($path);
     $pathInfo = pathinfo($path);
     return (new MediaEntity())->getConnection()->transaction(function () use($path, $pathInfo, $config) {
         $parent = $this->ensureDirectory(dirname($path));
         $media = MediaEntity::create(['hash' => array_key_exists('hash', $config) ? $config['hash'] : md5(uniqid('media', true)), 'ext' => null, 'type' => MediaEntity::TYPE_FILE, 'caption' => array_key_exists('caption ', $config) ? $config['caption'] : $pathInfo['basename'], 'parent_id' => array_key_exists('parent_id', $config) ? $config['parent_id'] : null]);
         $dir = dirname($media->realPath);
         if (@mkdir($dir, 0755, true) && !is_dir($dir)) {
             throw new \InvalidArgumentException();
         }
         if ($parent) {
             $media->makeChildOf($parent);
         } else {
             $media->makeRoot();
         }
         return $media;
     });
 }
开发者ID:rabbitcms,项目名称:filemanager,代码行数:29,代码来源:Media.php

示例11: getMetadata

 /**
  * @inheritdoc
  */
 public function getMetadata($path)
 {
     $path = Util::normalizePath($path);
     $this->assertPresent($path);
     return $this->getAdapter()->getMetadata($path);
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:9,代码来源:Filesystem.php

示例12: getRealPathName

 /**
  * {@inheritdoc}
  */
 public function getRealPathName($file)
 {
     return Util::normalizePath($file);
 }
开发者ID:flamecore,项目名称:synchronizer-files,代码行数:7,代码来源:FlysystemFilesLocation.php

示例13: openLockHandle

 /**
  * Creates an advisory lock handle.
  *
  * @return resource|false
  */
 protected function openLockHandle()
 {
     // PHP allows periods, '.', to be scheme names. Normalize the scheme
     // name to something that won't cause problems. Also, avoid problems
     // with case-insensitive filesystems. We use bin2hex() rather than a
     // hashing function since most scheme names are small, and bin2hex()
     // only doubles the string length.
     $sub_dir = bin2hex($this->getProtocol());
     // Since we're flattening out whole filesystems, at least create a
     // sub-directory for each scheme to attempt to reduce the number of
     // files per directory.
     $temp_dir = sys_get_temp_dir() . '/flysystem-stream-wrapper/' . $sub_dir;
     // Race free directory creation. If @mkdir() fails, fopen() will fail
     // later, so there's no reason to test again.
     !is_dir($temp_dir) && @mkdir($temp_dir, 0777, true);
     // Normalize paths so that locks are consistent.
     // We are using sha1() to avoid the file name limits, and case
     // insensitivity on Windows. This is not security sensitive.
     $lock_key = sha1(Util::normalizePath($this->getTarget()));
     // Relay the lock to a real filesystem lock.
     return fopen($temp_dir . '/' . $lock_key, 'c');
 }
开发者ID:twistor,项目名称:flysystem-stream-wrapper,代码行数:27,代码来源:FlysystemStreamWrapper.php

示例14: _joinPath

 /**
  * Join dir name and file name and return full path
  *
  * @param string $dir
  * @param string $name
  * @return string
  * @author Dmitry (dio) Levashov
  *
  */
 protected function _joinPath($dir, $name)
 {
     $phash = $this->encode($dir);
     // do not recursive search
     $searchExDirReg = $this->options['searchExDirReg'];
     $this->options['searchExDirReg'] = '/.*/';
     $search = $this->search($name, array(), $phash);
     $this->options['searchExDirReg'] = $searchExDirReg;
     if ($search) {
         foreach ($search as $r) {
             if ($r['phash'] === $phash && $r['name'] === $name) {
                 return Util::normalizePath($this->decode($r['hash']));
             }
         }
     }
     // reset stat cache of parent directory
     $this->clearcaches($phash);
     return Util::normalizePath($dir . $this->separator . $name);
 }
开发者ID:nao-pon,项目名称:elfinder-flysystem-driver-ext,代码行数:28,代码来源:Driver.php

示例15: normalizePath

 protected function normalizePath($path)
 {
     // Strip mount point from path, if needed
     if ($this->mountPoint && strpos($path, $this->mountPoint . '://') === 0) {
         $path = substr($path, strlen($this->mountPoint) + 3);
     }
     try {
         return Flysystem\Util::normalizePath($path);
     } catch (\LogicException $e) {
         throw new Ex\RootViolationException($e->getMessage(), $e->getCode(), $e);
     }
 }
开发者ID:pkdevboxy,项目名称:filesystem,代码行数:12,代码来源:Filesystem.php


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