- class
fs(php\lib\fs) - package
std - source
php/lib/fs.php
Description
File System class.
Class fs
fs ::separator()- Return the local filesystem's name-separator character.fs ::pathSeparator()- Return the local filesystem's path-separator character.fs ::valid()- Validate file name.fs ::abs()- Returns absolute real path.fs ::name()- Returns name of the path.fs ::nameNoExt()- Returns name of the path without extension.fs ::pathNoExt()- Returns path without extension.fs ::relativize()fs ::ext()- Returns extension of path.fs ::hasExt()- Check that $path has an extension from the extension set.fs ::parent()- Returns parent directory.fs ::ensureParent()- Checks parent of path and if it is not exists, tries to create parent directory.fs ::normalize()- Normalizes file path for current OS.fs ::exists()- Checks that file is exists.fs ::size()- Returns size of file in bytes.fs ::isFile()- Checks that path is file.fs ::isDir()- Checks that path is directory.fs ::isHidden()- Checks that path is hidden.fs ::time()- Returns last modification time of file or directory.fs ::makeDir()- Creates empty directory (mkdirs) if not exists.fs ::makeFile()- Creates empty file, if file already exists then rewrite it.fs ::delete()- Deletes file or empty directory.fs ::clean()- Deletes all files in path. This method does not delete the $path directory.fs ::scan()- Scans the path with callback or array filter and can returns found listfs ::crc32()- Calculates crc32 sum of file or stream, returns null if it's failed.fs ::hash()- Calculates hash of file or stream.fs ::copy()- Copies $source stream to $dest stream.fs ::move()- Renames or moves a file or empty dir.fs ::rename()- Set name for file, returns true if success.fs ::get()- Reads fully data from source and returns it as binary string.fs ::parseAs()- Read fully data from source, parse as format and return result.fs ::parse()- Read fully data from source, parse as format by extensions and return result.fs ::formatAs()- Write formatted data to source (path).fs ::format()- Write formatted (based on path extension) data to source (path).fs ::match()- Tells if given path matches this matcher's pattern.
fs::separator(): stringReturn the local filesystem's name-separator character.
fs::pathSeparator(): stringReturn the local filesystem's path-separator character.
fs::valid(mixed $name): boolValidate file name.
fs::abs(mixed $path): stringReturns absolute real path.
fs::name(mixed $path): stringReturns name of the path.
fs::nameNoExt(mixed $path): stringReturns name of the path without extension.
fs::pathNoExt(string $path): stringReturns path without extension.
fs::relativize(string $path, string $basePath): stringfs::ext(mixed $path): stringReturns extension of path.
fs::hasExt(string $path, string|array $extensions, bool $ignoreCase): boolCheck that $path has an extension from the extension set.
fs::parent(mixed $path): stringReturns parent directory.
fs::ensureParent(string $path): boolChecks parent of path and if it is not exists, tries to create parent directory. See makeDir().
fs::normalize(mixed $path): stringNormalizes file path for current OS.
fs::exists(mixed $path): stringChecks that file is exists.
fs::size(mixed $path): intReturns size of file in bytes.
fs::isFile(mixed $path): boolChecks that path is file.
fs::isDir(mixed $path): boolChecks that path is directory.
isHidden()
fs::isHidden(mixed $path): boolChecks that path is hidden.
fs::time(mixed $path): intReturns last modification time of file or directory.
fs::makeDir(string $path): boolCreates empty directory (mkdirs) if not exists.
fs::makeFile(mixed $path): boolCreates empty file, if file already exists then rewrite it.
fs::delete(mixed $path): boolDeletes file or empty directory.
fs::clean(string $path, callable|array $filter): arrayDeletes all files in path. This method does not delete the $path directory. Returns array with error, success and skip file list.
Array filter, e.g.: [ namePattern => string (regex), extensions => [...], excludeExtensions => [...], excludeDirs => bool, excludeFiles => bool, excludeHidden => bool,
minSize => int maxSize => int minTime => int, millis maxTime => int, millis
callback => function (File $file, $depth) { } ]
fs::scan(string $path, callable|array $filter, int $maxDepth, bool $subIsFirst): arrayScans the path with callback or array filter and can returns found list if the callback returns any result or if the callback is null.
Array filter, e.g.: [ namePattern => string (regex), extensions => [...], excludeExtensions => [...], excludeDirs => bool, excludeFiles => bool, excludeHidden => bool,
minSize => int maxSize => int minTime => int, millis maxTime => int, millis
callback => function (File $file, $depth) { } ]
fs::crc32(string|Stream $source): int|nullCalculates crc32 sum of file or stream, returns null if it's failed.
fs::hash(string|Stream $source, string $algo, callable $onProgress): string|nullCalculates hash of file or stream.
fs::copy(string|File|Stream $source, string|File|Stream $dest, callable $onProgress, int $bufferSize): intCopies $source stream to $dest stream.
fs::move(string $fromPath, string $toPath): boolRenames or moves a file or empty dir.
fs::rename(string $pathToFile, string $newName): boolSet name for file, returns true if success.
fs::get(string $source, null|string $charset, string $mode): stringReads fully data from source and returns it as binary string.
fs::parseAs(mixed $path, string $format, int $flags): mixedRead fully data from source, parse as format and return result.
fs::parse(mixed $path, int $flags): mixedRead fully data from source, parse as format by extensions and return result.
fs::formatAs(mixed $path, mixed $value, string $format, int $flags): voidWrite formatted data to source (path).
fs::format(mixed $path, mixed $value, int $flags): voidWrite formatted (based on path extension) data to source (path).
fs::match(string $path, string $fsPattern): boolTells if given path matches this matcher's pattern.