Файловый менеджер - Редактировать - /var/www/html/fileiteration.zip
Ðазад
PK ! J4~ SwiftFileBackendDirList.phpnu �Iw�� <?php /** * OpenStack Swift based file backend. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup FileBackend * @author Russ Nelson */ namespace Wikimedia\FileBackend\FileIteration; /** * Iterator for listing directories */ class SwiftFileBackendDirList extends SwiftFileBackendList { /** * @see Iterator::current() * @return string|bool String (relative path) or false */ #[\ReturnTypeWillChange] public function current() { return substr( current( $this->iterableBuffer ), $this->suffixStart, -1 ); } protected function pageFromList( $container, $dir, &$after, $limit, array $params ) { return $this->backend->getDirListPageInternal( $container, $dir, $after, $limit, $params ); } } /** @deprecated class alias since 1.43 */ class_alias( SwiftFileBackendDirList::class, 'SwiftFileBackendDirList' ); PK ! �*&�_ _ % FileBackendStoreShardListIterator.phpnu �Iw�� <?php /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup FileBackend */ namespace Wikimedia\FileBackend\FileIteration; use AppendIterator; use FilterIterator; use Iterator; use Wikimedia\FileBackend\FileBackendStore; /** * FileBackendStore helper function to handle listings that span container shards. * Do not use this class from places outside of FileBackendStore. * * @ingroup FileBackend */ abstract class FileBackendStoreShardListIterator extends FilterIterator { /** @var FileBackendStore */ protected $backend; /** @var array */ protected $params; /** @var string Full container name */ protected $container; /** @var string Resolved relative path */ protected $directory; /** @var array */ protected $multiShardPaths = []; // (rel path => 1) /** * @param FileBackendStore $backend * @param string $container Full storage container name * @param string $dir Storage directory relative to container * @param array $suffixes List of container shard suffixes * @param array $params */ public function __construct( FileBackendStore $backend, $container, $dir, array $suffixes, array $params ) { $this->backend = $backend; $this->container = $container; $this->directory = $dir; $this->params = $params; $iter = new AppendIterator(); foreach ( $suffixes as $suffix ) { $iter->append( $this->listFromShard( $this->container . $suffix ) ); } parent::__construct( $iter ); } public function accept(): bool { $inner = $this->getInnerIterator(); '@phan-var AppendIterator $inner'; $rel = $inner->current(); // path relative to given directory $path = $this->params['dir'] . "/{$rel}"; // full storage path if ( $this->backend->isSingleShardPathInternal( $path ) ) { return true; // path is only on one shard; no issue with duplicates } elseif ( isset( $this->multiShardPaths[$rel] ) ) { // Don't keep listing paths that are on multiple shards return false; } else { $this->multiShardPaths[$rel] = 1; return true; } } public function rewind(): void { parent::rewind(); $this->multiShardPaths = []; } /** * Get the list for a given container shard * * @param string $container Resolved container name * @return Iterator */ abstract protected function listFromShard( $container ); } /** @deprecated class alias since 1.43 */ class_alias( FileBackendStoreShardListIterator::class, 'FileBackendStoreShardListIterator' ); PK ! _C�,� � FSFileBackendFileList.phpnu �Iw�� <?php /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup FileBackend */ namespace Wikimedia\FileBackend\FileIteration; class FSFileBackendFileList extends FSFileBackendList { protected function filterViaNext() { while ( $this->iter->valid() ) { if ( !$this->iter->current()->isFile() ) { $this->iter->next(); // skip non-files and dot files } else { break; } } } } /** @deprecated class alias since 1.43 */ class_alias( FSFileBackendFileList::class, 'FSFileBackendFileList' ); PK ! �ɕ�� � SwiftFileBackendFileList.phpnu �Iw�� <?php /** * OpenStack Swift based file backend. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup FileBackend * @author Russ Nelson */ namespace Wikimedia\FileBackend\FileIteration; /** * Iterator for listing regular files */ class SwiftFileBackendFileList extends SwiftFileBackendList { /** * @see Iterator::current() * @return string|bool String (relative path) or false */ #[\ReturnTypeWillChange] public function current() { [ $path, $stat ] = current( $this->iterableBuffer ); $relPath = substr( $path, $this->suffixStart ); if ( is_array( $stat ) ) { $storageDir = rtrim( $this->params['dir'], '/' ); $this->backend->loadListingStatInternal( "$storageDir/$relPath", $stat ); } return $relPath; } protected function pageFromList( $container, $dir, &$after, $limit, array $params ) { return $this->backend->getFileListPageInternal( $container, $dir, $after, $limit, $params ); } } /** @deprecated class alias since 1.43 */ class_alias( SwiftFileBackendFileList::class, 'SwiftFileBackendFileList' ); PK ! žCj� � FSFileBackendList.phpnu �Iw�� <?php /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup FileBackend */ namespace Wikimedia\FileBackend\FileIteration; use DirectoryIterator; use FilesystemIterator; use Iterator; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use UnexpectedValueException; use Wikimedia\FileBackend\FileBackendError; /** * Wrapper around RecursiveDirectoryIterator/DirectoryIterator that * catches exception or does any custom behavior that we may want. * Do not use this class from places outside FSFileBackend. * * @ingroup FileBackend */ abstract class FSFileBackendList implements Iterator { /** @var Iterator|null */ protected $iter; /** @var string */ protected $lastError; /** @var int */ protected $suffixStart; /** @var int */ protected $pos = 0; /** @var array */ protected $params = []; /** * @param string $dir File system directory * @param array $params */ public function __construct( $dir, array $params ) { $path = realpath( $dir ); // normalize if ( $path === false ) { $path = $dir; } $this->suffixStart = strlen( $path ) + 1; // size of "path/to/dir/" $this->params = $params; try { $this->iter = $this->initIterator( $path ); } catch ( UnexpectedValueException $e ) { $this->iter = null; // bad permissions? deleted? $this->lastError = $e->getMessage(); } } /** * Return an appropriate iterator object to wrap * * @param string $dir File system directory * @return Iterator * @throws UnexpectedValueException */ protected function initIterator( $dir ) { if ( !empty( $this->params['topOnly'] ) ) { // non-recursive # Get an iterator that will get direct sub-nodes return new DirectoryIterator( $dir ); } else { // recursive # Get an iterator that will return leaf nodes (non-directories) # RecursiveDirectoryIterator extends FilesystemIterator. # FilesystemIterator::SKIP_DOTS default is inconsistent in PHP 5.3.x. $flags = FilesystemIterator::CURRENT_AS_SELF | FilesystemIterator::SKIP_DOTS; return new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $dir, $flags ), RecursiveIteratorIterator::CHILD_FIRST // include dirs ); } } /** * @see Iterator::key() * @return int */ public function key(): int { return $this->pos; } /** * @see Iterator::current() * @return string|false */ #[\ReturnTypeWillChange] public function current() { return $this->getRelPath( $this->iter->current()->getPathname() ); } /** * @see Iterator::next() * @throws FileBackendError */ public function next(): void { try { $this->iter->next(); $this->filterViaNext(); } catch ( UnexpectedValueException $e ) { // bad permissions? deleted? $this->lastError = $e->getMessage(); throw new FileBackendError( "File iterator gave UnexpectedValueException." ); } ++$this->pos; } /** * @see Iterator::rewind() * @throws FileBackendError */ public function rewind(): void { $this->pos = 0; try { $this->iter->rewind(); $this->filterViaNext(); } catch ( UnexpectedValueException $e ) { // bad permissions? deleted? $this->lastError = $e->getMessage(); throw new FileBackendError( "File iterator gave UnexpectedValueException." ); } } /** * @see Iterator::valid() * @return bool */ public function valid(): bool { return $this->iter && $this->iter->valid(); } /** * @return string|null The last caught exception message */ public function getLastError() { return $this->lastError; } /** * Filter out items by advancing to the next ones */ protected function filterViaNext() { } /** * Return only the relative path and normalize slashes to FileBackend-style. * Uses the "real path" since the suffix is based upon that. * * @param string $dir * @return string */ protected function getRelPath( $dir ) { $path = realpath( $dir ); if ( $path === false ) { $path = $dir; } return strtr( substr( $path, $this->suffixStart ), '\\', '/' ); } } /** @deprecated class alias since 1.43 */ class_alias( FSFileBackendList::class, 'FSFileBackendList' ); PK ! �+�� � FSFileBackendDirList.phpnu �Iw�� <?php /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup FileBackend */ namespace Wikimedia\FileBackend\FileIteration; class FSFileBackendDirList extends FSFileBackendList { protected function filterViaNext() { while ( $this->iter->valid() ) { if ( $this->iter->current()->isDot() || !$this->iter->current()->isDir() ) { $this->iter->next(); // skip non-directories and dot files } else { break; } } } } /** @deprecated class alias since 1.43 */ class_alias( FSFileBackendDirList::class, 'FSFileBackendDirList' ); PK ! �ڕ�� � % FileBackendStoreShardFileIterator.phpnu �Iw�� <?php /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup FileBackend */ namespace Wikimedia\FileBackend\FileIteration; use ArrayIterator; /** * Iterator for listing regular files */ class FileBackendStoreShardFileIterator extends FileBackendStoreShardListIterator { protected function listFromShard( $container ) { $list = $this->backend->getFileListInternal( $container, $this->directory, $this->params ); if ( $list === null ) { return new ArrayIterator( [] ); } else { // @phan-suppress-next-line PhanTypeMismatchReturnSuperType return is_array( $list ) ? new ArrayIterator( $list ) : $list; } } } /** @deprecated class alias since 1.43 */ class_alias( FileBackendStoreShardFileIterator::class, 'FileBackendStoreShardFileIterator' ); PK ! �%n�� � $ FileBackendStoreShardDirIterator.phpnu �Iw�� <?php /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup FileBackend */ namespace Wikimedia\FileBackend\FileIteration; use ArrayIterator; /** * Iterator for listing directories */ class FileBackendStoreShardDirIterator extends FileBackendStoreShardListIterator { protected function listFromShard( $container ) { $list = $this->backend->getDirectoryListInternal( $container, $this->directory, $this->params ); if ( $list === null ) { return new ArrayIterator( [] ); } else { // @phan-suppress-next-line PhanTypeMismatchReturnSuperType return is_array( $list ) ? new ArrayIterator( $list ) : $list; } } } /** @deprecated class alias since 1.43 */ class_alias( FileBackendStoreShardDirIterator::class, 'FileBackendStoreShardDirIterator' ); PK ! �v/� � SwiftFileBackendList.phpnu �Iw�� <?php /** * OpenStack Swift based file backend. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup FileBackend * @author Russ Nelson */ namespace Wikimedia\FileBackend\FileIteration; use Iterator; use Traversable; use Wikimedia\FileBackend\SwiftFileBackend; /** * SwiftFileBackend helper class to page through listings. * Swift also has a listing limit of 10,000 objects for performance. * Do not use this class from places outside SwiftFileBackend. * * @ingroup FileBackend */ abstract class SwiftFileBackendList implements Iterator { /** @var string[]|array[] Current page of entries; path list or (path,stat map) list */ protected $iterableBuffer = []; /** @var string|null Continuation marker; the next page starts *after* this path */ protected $continueAfter = null; /** @var int */ protected $pos = 0; /** @var array */ protected $params = []; /** @var SwiftFileBackend */ protected $backend; /** @var string Container name */ protected $container; /** @var string Storage directory */ protected $dir; /** @var int */ protected $suffixStart; private const PAGE_SIZE = 9000; // file listing buffer size /** * @param SwiftFileBackend $backend * @param string $fullCont Resolved container name * @param string $dir Resolved directory relative to container * @param array $params * @note This defers I/O by not buffering the first page (useful for AppendIterator use) * @note Do not call current()/valid() without calling rewind() first */ public function __construct( SwiftFileBackend $backend, $fullCont, $dir, array $params ) { $this->backend = $backend; $this->container = $fullCont; $this->dir = $dir; if ( substr( $this->dir, -1 ) === '/' ) { $this->dir = substr( $this->dir, 0, -1 ); // remove trailing slash } if ( $this->dir == '' ) { // whole container $this->suffixStart = 0; } else { // dir within container $this->suffixStart = strlen( $this->dir ) + 1; // size of "path/to/dir/" } $this->params = $params; } /** * @see Iterator::key() * @return int */ public function key(): int { return $this->pos; } /** * @inheritDoc */ public function next(): void { ++$this->pos; if ( $this->iterableBuffer === null ) { // Last page of entries failed to load return; } // Advance to the next entry in the page next( $this->iterableBuffer ); // Check if there are no entries left in this page and // advance to the next page if this page was not empty. if ( !$this->valid() && count( $this->iterableBuffer ) ) { $this->iterableBuffer = $this->pageFromList( $this->container, $this->dir, $this->continueAfter, self::PAGE_SIZE, $this->params ); } } /** * @inheritDoc */ public function rewind(): void { $this->pos = 0; $this->continueAfter = null; $this->iterableBuffer = $this->pageFromList( $this->container, $this->dir, // @phan-suppress-next-line PhanTypeMismatchArgumentPropertyReferenceReal $this->continueAfter, self::PAGE_SIZE, $this->params ); } /** * @see Iterator::valid() * @return bool */ public function valid(): bool { if ( $this->iterableBuffer === null ) { // Last page of entries failed to load return false; } // Note that entries (paths/tuples) are never boolean return ( current( $this->iterableBuffer ) !== false ); } /** * Get the next page of entries * * @param string $container Resolved container name * @param string $dir Resolved path relative to container * @param string &$after @phan-output-reference Continuation marker * @param int $limit * @param array $params * @return Traversable|array */ abstract protected function pageFromList( $container, $dir, &$after, $limit, array $params ); } /** @deprecated class alias since 1.43 */ class_alias( SwiftFileBackendList::class, 'SwiftFileBackendList' ); PK ! J4~ SwiftFileBackendDirList.phpnu �Iw�� PK ! �*&�_ _ % c FileBackendStoreShardListIterator.phpnu �Iw�� PK ! _C�,� � FSFileBackendFileList.phpnu �Iw�� PK ! �ɕ�� � 6 SwiftFileBackendFileList.phpnu �Iw�� PK ! žCj� � s FSFileBackendList.phpnu �Iw�� PK ! �+�� � �2 FSFileBackendDirList.phpnu �Iw�� PK ! �ڕ�� � % �7 FileBackendStoreShardFileIterator.phpnu �Iw�� PK ! �%n�� � $ >