本文整理汇总了PHP中League\Flysystem\Filesystem::listFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::listFiles方法的具体用法?PHP Filesystem::listFiles怎么用?PHP Filesystem::listFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::listFiles方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getArchives
/**
* {@inheritdoc}
*/
public function getArchives(JobExecution $jobExecution)
{
$directory = dirname($this->getRelativeArchivePath($jobExecution));
$archives = [];
foreach ($this->filesystem->listFiles($directory) as $key) {
$archives[basename($key['path'])] = $key['path'];
}
return $archives;
}
示例2: getFiles
/**
* @return array
*/
public function getFiles()
{
if (!$this->files) {
$this->files = $this->fs->listFiles($this->getDirectory(), true);
foreach ($this->files as &$file) {
$this->addData($file);
}
}
return $this->files;
}
示例3: getFilesList
/**
* {@inheritdoc}
*/
public function getFilesList($exclude = false)
{
$fileslist = array();
$files = $this->filesystem->listFiles('', true);
foreach ($files as $file) {
$filename = basename($file['path']);
$dirname = dirname($file['path']);
$fileslist[$dirname][$filename] = $file['path'];
}
return $fileslist;
}
示例4: pruneStorage
/**
* @return int
*/
public function pruneStorage()
{
if (!$this->options->getPruneMaxCount() && !$this->options->getPruneMaxTtl()) {
return 0;
}
// save to just add
$this->filesystem->addPlugin(new ListFiles());
$filesInBackup = $this->filesystem->listFiles($this->options->getPath());
// filter latest.txt
if ($this->options->getWriteLatest()) {
$filesInBackup = array_filter($filesInBackup, function ($item) {
return $item['basename'] != $this->options->getWriteLatest();
});
}
// sort on timestamp
usort($filesInBackup, function ($item1, $item2) {
return strcmp($item1['timestamp'], $item2['timestamp']);
});
$pruneCount = 0;
// remove while count >= pruneMaxCount or timestamp < now - pruneMaxTtl
while ($last = array_shift($filesInBackup)) {
if ($this->options->getPruneMaxCount()) {
if (count($filesInBackup) >= $this->options->getPruneMaxCount()) {
$this->filesystem->delete($last['path']);
$pruneCount++;
continue;
}
}
if ($this->options->getPruneMaxTtl()) {
if ($last['timestamp'] < time() - $this->options->getPruneMaxTtl()) {
$this->filesystem->delete($last['path']);
$pruneCount++;
continue;
}
}
}
return $pruneCount;
}
示例5: restore
/**
* {@inheritdoc}
*
* @throws FileExistsException
* @throws \InvalidArgumentException
* @throws FileNotFoundException
* @throws LogicException
*/
public function restore(Filesystem $source, Filesystem $destination, ReadonlyDatabase $database, array $parameter)
{
// TODO make it smoother
$files = $source->listFiles('', true);
$progressBar = new ProgressBar($this->output, count($files));
$progressBar->setOverwrite(true);
$progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
$progressBar->start();
foreach ($files as $file) {
$path = $file['path'];
$fullPath = $parameter['directory'] . '/' . $file['path'];
if ($destination->has($fullPath)) {
if ($destination->hash($fullPath) === $source->hash($path)) {
$progressBar->advance();
continue;
}
$destination->delete($fullPath);
}
$destination->writeStream($fullPath, $source->readStream($path));
$progressBar->advance();
}
$progressBar->finish();
}
示例6: testRemoteListing
public function testRemoteListing()
{
$this->remoteFilesystem->listFiles($this->name)->willReturn([['filename' => 'test-1'], ['filename' => 'test-2']]);
$this->assertEquals(['test-1', 'test-2'], $this->storage->remoteListing());
}
示例7: getChunks
public function getChunks($uuid)
{
$results = $this->filesystem->listFiles($this->prefix . '/' . $uuid);
return preg_grep('/^.+\\/(\\d+)_/', $results['keys']);
}
示例8: listing
/**
* @param Filesystem $filesystem
*
* @return string[]
*/
protected function listing(Filesystem $filesystem)
{
return array_filter(array_map(function ($item) {
return $item['filename'];
}, $filesystem->listFiles($this->name)));
}
示例9: listFiles
/**
* List all the files from a directory
*
* @param string $directory
* @param bool $recursive
* @return array
*/
public function listFiles($directory = null, $recursive = false)
{
return $this->flysystem->listFiles($directory, $recursive);
}
示例10: getListing
/**
* @return array
*/
public function getListing()
{
return $this->filesystem->listFiles();
}