- 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(): string
Return the local filesystem's name-separator character.
fs::pathSeparator(): string
Return the local filesystem's path-separator character.
fs::valid(mixed $name): bool
Validate file name.
fs::abs(mixed $path): string
Returns absolute real path.
fs::name(mixed $path): string
Returns name of the path.
fs::nameNoExt(mixed $path): string
Returns name of the path without extension.
fs::pathNoExt(string $path): string
Returns path without extension.
fs::relativize(string $path, string $basePath): string
fs::ext(mixed $path): string
Returns extension of path.
fs::hasExt(string $path, string|array $extensions, bool $ignoreCase): bool
Check that $path has an extension from the extension set.
fs::parent(mixed $path): string
Returns parent directory.
fs::ensureParent(string $path): bool
Checks parent of path and if it is not exists, tries to create parent directory. See makeDir().
fs::normalize(mixed $path): string
Normalizes file path for current OS.
fs::exists(mixed $path): string
Checks that file is exists.
fs::size(mixed $path): int
Returns size of file in bytes.
fs::isFile(mixed $path): bool
Checks that path is file.
fs::isDir(mixed $path): bool
Checks that path is directory.
isHidden()
fs::isHidden(mixed $path): bool
Checks that path is hidden.
fs::time(mixed $path): int
Returns last modification time of file or directory.
fs::makeDir(string $path): bool
Creates empty directory (mkdirs) if not exists.
fs::makeFile(mixed $path): bool
Creates empty file, if file already exists then rewrite it.
fs::delete(mixed $path): bool
Deletes file or empty directory.
fs::clean(string $path, callable|array $filter): array
Deletes 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): array
Scans 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|null
Calculates crc32 sum of file or stream, returns null if it's failed.
fs::hash(string|Stream $source, string $algo, callable $onProgress): string|null
Calculates hash of file or stream.
fs::copy(string|File|Stream $source, string|File|Stream $dest, callable $onProgress, int $bufferSize): int
Copies $source stream to $dest stream.
fs::move(string $fromPath, string $toPath): bool
Renames or moves a file or empty dir.
fs::rename(string $pathToFile, string $newName): bool
Set name for file, returns true if success.
fs::get(string $source, null|string $charset, string $mode): string
Reads fully data from source and returns it as binary string.
fs::parseAs(mixed $path, string $format, int $flags): mixed
Read fully data from source, parse as format and return result.
fs::parse(mixed $path, int $flags): mixed
Read fully data from source, parse as format by extensions and return result.
fs::formatAs(mixed $path, mixed $value, string $format, int $flags): void
Write formatted data to source (path).
fs::format(mixed $path, mixed $value, int $flags): void
Write formatted (based on path extension) data to source (path).
fs::match(string $path, string $fsPattern): bool
Tells if given path matches this matcher's pattern.