FileSystem
final class FileSystem
File system tool.
Methods
Creates a directory if it doesn't exist.
Copies a file or a directory. Overwrites existing files and directories by default.
Deletes a file or directory if exists.
Renames or moves a file or a directory. Overwrites existing files and directories by default.
Reads the content of a file.
Writes the string to a file.
Fixes permissions to a specific file or directory. Directories can be fixed recursively.
Determines if the path is absolute.
Normalizes ..
and .
and directory separators in path.
Joins all segments of the path and normalizes the result.
Details
at line 26
static void
createDir(string $dir, int $mode = 0777)
Creates a directory if it doesn't exist.
at line 44
static void
copy(string $origin, string $target, bool $overwrite = true)
Copies a file or a directory. Overwrites existing files and directories by default.
at line 87
static void
delete(string $path)
Deletes a file or directory if exists.
at line 119
static void
rename(string $origin, string $target, bool $overwrite = true)
Renames or moves a file or a directory. Overwrites existing files and directories by default.
at line 148
static string
read(string $file)
Reads the content of a file.
at line 166
static void
write(string $file, string $content, int|null $mode = 0666)
Writes the string to a file.
at line 191
static void
makeWritable(string $path, int $dirMode = 0777, int $fileMode = 0666)
Fixes permissions to a specific file or directory. Directories can be fixed recursively.
at line 223
static bool
isAbsolute(string $path)
Determines if the path is absolute.
at line 232
static string
normalizePath(string $path)
Normalizes ..
and .
and directory separators in path.
at line 252
static string
joinPaths(string ...$paths)
Joins all segments of the path and normalizes the result.
Traits
Static class.