public function opendir($path) { $path = $this->normalizePath($path); if ($path === '.') { $path = ''; } else { $path .= '/'; } $path = str_replace('%23', '#', $path); // the prefix is sent as a query param, so revert the encoding of # try { $files = array(); /** @var OpenCloud\Common\Collection $objects */ $objects = $this->getContainer()->objectList(array('prefix' => $path, 'delimiter' => '/')); /** @var OpenCloud\ObjectStore\Resource\DataObject $object */ foreach ($objects as $object) { $file = basename($object->getName()); if ($file !== basename($path)) { $files[] = $file; } } return IteratorDirectory::wrap($files); } catch (\Exception $e) { \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); return false; } }
public function opendir($path) { $contents = $this->getDropBoxMetaData($path, true); if ($contents !== false) { $files = array(); foreach ($contents as $file) { $files[] = basename($file['path']); } return IteratorDirectory::wrap($files); } return false; }
public function opendir($path) { try { $files = $this->getFolderContents($path); } catch (NotFoundException $e) { return false; } catch (ForbiddenException $e) { return false; } $names = array_map(function ($info) { /** @var \Icewind\SMB\IFileInfo $info */ return $info->getName(); }, $files); return IteratorDirectory::wrap($names); }
public function opendir($path) { $files = $this->getFolderContents($path); $names = array_map(function ($info) { /** @var \Icewind\SMB\IFileInfo $info */ return $info->getName(); }, $files); return IteratorDirectory::wrap($names); }
/** {@inheritdoc} */ public function opendir($path) { $this->init(); $path = $this->cleanPath($path); try { $response = $this->client->propfind($this->encodePath($path), array(), 1); $id = md5('webdav' . $this->root . $path); $content = array(); $files = array_keys($response); array_shift($files); //the first entry is the current directory if (!$this->statCache->hasKey($path)) { $this->statCache->set($path, true); } foreach ($files as $file) { $file = urldecode($file); // do not store the real entry, we might not have all properties if (!$this->statCache->hasKey($path)) { $this->statCache->set($file, true); } $file = basename($file); $content[] = $file; } return IteratorDirectory::wrap($content); } catch (ClientHttpException $e) { if ($e->getHttpStatus() === 404) { $this->statCache->clear($path . '/'); $this->statCache->set($path, false); return false; } $this->convertException($e, $path); } catch (\Exception $e) { $this->convertException($e, $path); } return false; }
public function opendir($path) { $path = $this->normalizePath($path); try { $files = array(); $folderContents = $this->getCache()->getFolderContents($path); foreach ($folderContents as $file) { $files[] = $file['name']; } return IteratorDirectory::wrap($files); } catch (\Exception $e) { \OCP\Util::writeLog('objectstore', $e->getMessage(), \OCP\Util::ERROR); return false; } }
/** * {@inheritdoc} */ public function opendir($path) { try { $list = $this->getConnection()->nlist($this->absPath($path)); if ($list === false) { return false; } $id = md5('sftp:' . $path); $dirStream = array(); foreach ($list as $file) { if ($file != '.' && $file != '..') { $dirStream[] = $file; } } return IteratorDirectory::wrap($dirStream); } catch (\Exception $e) { return false; } }
public function opendir($path) { $path = $this->normalizePath($path); if ($this->isRoot($path)) { $path = ''; } else { $path .= '/'; } try { $files = array(); $result = $this->getConnection()->getIterator('ListObjects', array('Bucket' => $this->bucket, 'Delimiter' => '/', 'Prefix' => $path), array('return_prefixes' => true)); foreach ($result as $object) { if (isset($object['Key']) && $object['Key'] === $path) { // it's the directory itself, skip continue; } $file = basename(isset($object['Key']) ? $object['Key'] : $object['Prefix']); $files[] = $file; } return IteratorDirectory::wrap($files); } catch (S3Exception $e) { \OCP\Util::logException('files_external', $e); return false; } }
/** * {@inheritdoc} */ public function opendir($path) { try { $content = $this->flysystem->listContents($this->buildPath($path)); } catch (FileNotFoundException $e) { return false; } $names = array_map(function ($object) { return $object['basename']; }, $content); return IteratorDirectory::wrap($names); }
public function opendir($path) { $folder = $this->getDriveFile($path); if ($folder) { $files = array(); $duplicates = array(); $pageToken = true; while ($pageToken) { $params = array(); if ($pageToken !== true) { $params['pageToken'] = $pageToken; } $params['q'] = "'" . str_replace("'", "\\'", $folder->getId()) . "' in parents and trashed = false"; $children = $this->service->files->listFiles($params); foreach ($children->getItems() as $child) { $name = $child->getTitle(); // Check if this is a Google Doc i.e. no extension in name if (empty($child->getFileExtension()) && $child->getMimeType() !== self::FOLDER) { $name .= '.' . $this->getGoogleDocExtension($child->getMimeType()); } if ($path === '') { $filepath = $name; } else { $filepath = $path . '/' . $name; } // Google Drive allows files with the same name, ownCloud doesn't // Prevent opendir() from returning any duplicate files $key = array_search($name, $files); if ($key !== false || isset($duplicates[$filepath])) { if (!isset($duplicates[$filepath])) { $duplicates[$filepath] = true; $this->setDriveFile($filepath, false); unset($files[$key]); $this->onDuplicateFileDetected($filepath); } } else { // Cache the Google_Service_Drive_DriveFile for future use $this->setDriveFile($filepath, $child); $files[] = $name; } } $pageToken = $children->getNextPageToken(); } return IteratorDirectory::wrap($files); } else { return false; } }
/** * @param \Iterator | array $source * @return resource */ protected function wrapSource($source) { return \Icewind\Streams\IteratorDirectory::wrap($source); }