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


PHP Util::dirname方法代码示例

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


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

示例1: listContents

 public function listContents($directory = '', $recursive = false)
 {
     $filter = function (&$value, $path) use($directory) {
         if (Util::dirname($path) !== $directory) {
             $value = null;
         }
     };
     $list = $this->client->lists($directory, $recursive ? null : $filter);
     return $list;
 }
开发者ID:litp,项目名称:flysystem-sae,代码行数:10,代码来源:KvdbAdapter.php

示例2: rename

 public function rename($path, $newpath)
 {
     $location = $this->applyPathPrefix($path);
     $destination = $this->applyPathPrefix($newpath);
     $parentDirectory = $this->applyPathPrefix(Util::dirname($newpath));
     if (!$this->ensureDirectory($parentDirectory)) {
         return false;
     }
     return rename($location, $destination);
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:10,代码来源:Local.php

示例3: isValidRename

 /**
  * Checks that a rename is valid.
  *
  * @param string $source
  * @param string $dest
  *
  * @return bool
  */
 protected function isValidRename($source, $dest)
 {
     $adapter = $this->filesystem->getAdapter();
     if (!$adapter->has($source)) {
         throw new FileNotFoundException($source);
     }
     $subdir = Util::dirname($dest);
     if (strlen($subdir) && !$adapter->has($subdir)) {
         throw new FileNotFoundException($source);
     }
     if (!$adapter->has($dest)) {
         return true;
     }
     return $this->compareTypes($source, $dest);
 }
开发者ID:twistor,项目名称:flysystem-stream-wrapper,代码行数:23,代码来源:ForcedRename.php

示例4: write

 /**
  * {@inheritdoc}
  */
 public function write($path, $contents, Config $config)
 {
     $location = $this->applyPathPrefix($path);
     $dirname = Util::dirname($path);
     if (!empty($dirname) && !$this->has($dirname)) {
         $this->createDir($dirname, $config);
     }
     if (!$this->archive->addFromString($location, $contents)) {
         return false;
     }
     $result = compact('path', 'contents');
     if ($config && $config->get('visibility')) {
         throw new LogicException(get_class($this) . ' does not support visibility settings.');
     }
     return $result;
 }
开发者ID:johnkewforks,项目名称:filemanager-backend,代码行数:19,代码来源:ZipArchiveAdapter.php

示例5: listContents

 /**
  * @inheritdoc
  */
 public function listContents($directory = '', $recursive = false)
 {
     $directory = Util::normalizePath($directory);
     $contents = $this->getAdapter()->listContents($directory, $recursive);
     $filter = function (array $entry) use($directory, $recursive) {
         if (empty($entry['path']) && $entry['path'] !== '0') {
             return false;
         }
         if ($recursive) {
             return $directory === '' || strpos($entry['path'], $directory . '/') === 0;
         }
         return Util::dirname($entry['path']) === $directory;
     };
     $mapper = function (array $entry) {
         return $entry + Util::pathinfo($entry['path']);
     };
     $listing = array_values(array_map($mapper, array_filter($contents, $filter)));
     usort($listing, function ($a, $b) {
         return strcasecmp($a['path'], $b['path']);
     });
     return $listing;
 }
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:25,代码来源:Filesystem.php

示例6: normalizeObject

 /**
  * {@inheritdoc}
  */
 protected function normalizeObject(DataObject $object)
 {
     $name = $object->getName();
     $name = $this->removePathPrefix($name);
     $mimetype = explode('; ', $object->getContentType());
     return ['type' => in_array('application/directory', $mimetype) ? 'dir' : 'file', 'dirname' => Util::dirname($name), 'path' => $name, 'timestamp' => strtotime($object->getLastModified()), 'mimetype' => reset($mimetype), 'size' => $object->getContentLength()];
 }
开发者ID:jiiis,项目名称:ptn,代码行数:10,代码来源:RackspaceAdapter.php

示例7: _dirname

 /**
  * Return parent directory path
  *
  * @param  string  $path  file path
  * @return string
  **/
 protected function _dirname($path)
 {
     return Util::dirname($path) ?: '/';
 }
开发者ID:quepasso,项目名称:dashboard,代码行数:10,代码来源:ElFinderVolumeFlysystem.php

示例8: listContents

 /**
  * List the filesystem contents.
  *
  * @param string $directory
  * @param bool   $recursive
  *
  * @return array contents
  */
 public function listContents($directory = '', $recursive = false)
 {
     $directory = Util::normalizePath($directory);
     $contents = $this->adapter->listContents($directory, $recursive);
     $mapper = function ($entry) use($directory, $recursive) {
         $entry = $entry + Util::pathinfo($entry['path']);
         if (!empty($directory) && strpos($entry['path'], $directory) === false) {
             return false;
         }
         if ($recursive === false && Util::dirname($entry['path']) !== $directory) {
             return false;
         }
         return $entry;
     };
     return array_values(array_filter(array_map($mapper, $contents)));
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:24,代码来源:Filesystem.php

示例9: isDirectChild

 /**
  * Check if the entry is a direct child of the directory.
  *
  * @param $entry
  *
  * @return bool
  */
 private function isDirectChild(array $entry)
 {
     return Util::dirname($entry['path']) === $this->directory;
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:11,代码来源:ContentListingFormatter.php

示例10: has

 /**
  * {@inheritdoc}
  */
 public function has($path)
 {
     if (array_key_exists($path, $this->cache)) {
         return $this->cache[$path] !== false;
     }
     if ($this->isComplete(Util::dirname($path), false)) {
         return false;
     }
 }
开发者ID:slion0725,项目名称:admin_ci303,代码行数:12,代码来源:AbstractCache.php

示例11: normalizeObject

 /**
  * Normalize a result from Google
  *
  * @param   string  $object
  * @param   string  $path
  * @return  array   file metadata
  */
 protected function normalizeObject($object, $path = null)
 {
     $newObject = array();
     foreach ((array) $object as $key => $value) {
         if (substr($key, 0, 3) == "*") {
             $key = substr($key, 3);
         }
         $newObject[$key] = $value;
     }
     $object = $newObject;
     if (isset($object["dirname"])) {
         $result = array('path' => $object['dirname'] . "/" . $object['id']);
     } else {
         $result = array('path' => $object['id']);
     }
     if (isset($object['modifiedDate'])) {
         $result['timestamp'] = strtotime($object['modifiedDate']);
     }
     $result["basename"] = $object["title"];
     if ($object['mimeType'] == 'application/vnd.google-apps.folder') {
         $result['type'] = 'dir';
         $result['path'] = rtrim($result['path'], '/');
         $result['dirname'] = Util::dirname($result['path']);
         return $result;
     }
     $result = array_merge($result, Util::map($object, static::$resultMap), array('type' => 'file'));
     $result['dirname'] = Util::dirname($result['path']);
     if (isset($result['contents'])) {
         $result['contents'] = (string) $result['contents'];
     }
     return $result;
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:39,代码来源:GoogleDrive.php

示例12: listContents

 /**
  * @inheritdoc
  */
 public function listContents($directory = '', $recursive = false)
 {
     $directory = Util::normalizePath($directory);
     $adapter = $this->getAdapter();
     $separator = $adapter instanceof Local ? DIRECTORY_SEPARATOR : '/';
     $contents = $adapter->listContents($directory, $recursive);
     $mapper = function ($entry) use($directory, $recursive, $separator) {
         if (strlen($entry['path']) === 0 || !empty($directory) && strpos($entry['path'], $directory . $separator) === false || $recursive === false && Util::dirname($entry['path']) !== $directory) {
             return false;
         }
         return $entry + Util::pathinfo($entry['path']);
     };
     $listing = array_values(array_filter(array_map($mapper, $contents)));
     usort($listing, function ($a, $b) {
         return strcasecmp($a['path'], $b['path']);
     });
     return $listing;
 }
开发者ID:shinichi81,项目名称:simpleAuth,代码行数:21,代码来源:Filesystem.php

示例13: writeStream

 public function writeStream($path, $resource, $config = null)
 {
     $this->ensureDirectory(Util::dirname($path));
     $config = Util::ensureConfig($config);
     if (!ftp_fput($this->getConnection(), $path, $resource, FTP_BINARY)) {
         return false;
     }
     if ($visibility = $config->get('visibility')) {
         $this->setVisibility($path, $visibility);
     }
     return compact('path', 'visibility');
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:12,代码来源:Ftp.php

示例14: ensureSubDirs

 /**
  * Ensures that the sub-directories of a directory exist.
  *
  * @param string      $directory The directory.
  * @param Config|null $config    Optionl configuration.
  *
  * @return bool True on success, false on failure.
  */
 protected function ensureSubDirs($directory, Config $config = null)
 {
     $config = $config ?: new Config();
     return $this->createDir(Util::dirname($directory), $config);
 }
开发者ID:twistor,项目名称:flysystem-memory-adapter,代码行数:13,代码来源:MemoryAdapter.php

示例15: upload

 /**
  * Upload|Update item
  *
  * @param string $path
  * @param string|resource $contents
  * @param Config $config
  *
  * @return array|false item info array
  */
 protected function upload($path, $contents, Config $config)
 {
     list($parentId, $fileName) = $this->splitPath($path);
     $mode = 'update';
     $mime = $config->get('mimetype');
     $srcFile = $this->getFileObject($path);
     $file = new Google_Service_Drive_DriveFile();
     if (!$srcFile) {
         $mode = 'insert';
         $file->setName($fileName);
         $file->setParents([$parentId]);
     }
     $isResource = false;
     if (is_resource($contents)) {
         $fstat = @fstat($contents);
         if (!empty($fstat['size'])) {
             $isResource = true;
         }
         if (!$isResource) {
             $contents = stream_get_contents($contents);
         }
     }
     if ($isResource) {
         // set chunk size (max: 100MB)
         $chunkSizeBytes = 100 * 1024 * 1024;
         $memory = $this->getIniBytes('memory_limit');
         if ($memory) {
             $chunkSizeBytes = min([$chunkSizeBytes, intval($memory / 4 / 256) * 256]);
         }
         if ($fstat['size'] < $chunkSizeBytes) {
             $isResource = false;
             $contents = stream_get_contents($contents);
         }
     }
     if (!$mime) {
         $mime = Util::guessMimeType($fileName, $isResource ? '' : $contents);
     }
     $file->setMimeType($mime);
     if ($isResource) {
         $client = $this->service->getClient();
         // Call the API with the media upload, defer so it doesn't immediately return.
         $client->setDefer(true);
         if ($mode === 'insert') {
             $request = $this->service->files->create($file, ['fields' => self::FETCHFIELDS_GET]);
         } else {
             $request = $this->service->files->update($srcFile->getId(), $file, ['fields' => self::FETCHFIELDS_GET]);
         }
         // Create a media file upload to represent our upload process.
         $media = new Google_Http_MediaFileUpload($client, $request, $mime, null, true, $chunkSizeBytes);
         $media->setFileSize($fstat['size']);
         // Upload the various chunks. $status will be false until the process is
         // complete.
         $status = false;
         $handle = $contents;
         while (!$status && !feof($handle)) {
             // read until you get $chunkSizeBytes from TESTFILE
             // fread will never return more than 8192 bytes if the stream is read buffered and it does not represent a plain file
             // An example of a read buffered file is when reading from a URL
             $chunk = $this->readFileChunk($handle, $chunkSizeBytes);
             $status = $media->nextChunk($chunk);
         }
         // The final value of $status will be the data from the API for the object
         // that has been uploaded.
         if ($status != false) {
             $obj = $status;
         }
         $client->setDefer(false);
     } else {
         $params = ['data' => $contents, 'uploadType' => 'media', 'fields' => self::FETCHFIELDS_GET];
         if ($mode === 'insert') {
             $obj = $this->service->files->create($file, $params);
         } else {
             $obj = $this->service->files->update($srcFile->getId(), $file, $params);
         }
     }
     if ($obj instanceof Google_Service_Drive_DriveFile) {
         $this->cacheFileObjects[$obj->getId()] = $obj;
         if ($mode === 'insert') {
             $this->cacheFileObjects[$fileName] = $obj;
         }
         $result = $this->normaliseObject($obj, Util::dirname($path));
         if ($visibility = $config->get('visibility')) {
             if ($this->setVisibility($path, $visibility)) {
                 $result['visibility'] = $visibility;
             }
         }
         return $result;
     }
     return false;
 }
开发者ID:nao-pon,项目名称:flysystem-google-drive,代码行数:99,代码来源:GoogleDriveAdapter.php


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