當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。