$lastError
$lastError :
Provides basic utility to manipulate the file system.
copy(string $originFile, string $targetFile, boolean $overwriteNewerFiles = false)
Copies a file.
If the target file is older than the origin file, it's always overwritten. If the target file is newer, it is overwritten only when the $overwriteNewerFiles option is set to true.
string | $originFile | The original filename |
string | $targetFile | The target filename |
boolean | $overwriteNewerFiles | If true, target files newer than origin files are overwritten |
When originFile doesn't exist
When copy fails
mkdir(string|\Symfony\Component\Filesystem\iterable $dirs, integer $mode = 511)
Creates a directory recursively.
string|\Symfony\Component\Filesystem\iterable | $dirs | The directory path |
integer | $mode | The directory mode |
On any directory creation failure
exists(string|\Symfony\Component\Filesystem\iterable $files) : boolean
Checks the existence of files or directories.
string|\Symfony\Component\Filesystem\iterable | $files | A filename, an array of files, or a \Traversable instance to check |
true if the file exists, false otherwise
touch(string|\Symfony\Component\Filesystem\iterable $files, integer $time = null, integer $atime = null)
Sets access and modification time of file.
string|\Symfony\Component\Filesystem\iterable | $files | A filename, an array of files, or a \Traversable instance to create |
integer | $time | The touch time as a Unix timestamp |
integer | $atime | The access time as a Unix timestamp |
When touch fails
remove(string|\Symfony\Component\Filesystem\iterable $files)
Removes files or directories.
string|\Symfony\Component\Filesystem\iterable | $files | A filename, an array of files, or a \Traversable instance to remove |
When removal fails
chmod(string|\Symfony\Component\Filesystem\iterable $files, integer $mode, integer $umask, boolean $recursive = false)
Change mode for an array of files or directories.
string|\Symfony\Component\Filesystem\iterable | $files | A filename, an array of files, or a \Traversable instance to change mode |
integer | $mode | The new mode (octal) |
integer | $umask | The mode mask (octal) |
boolean | $recursive | Whether change the mod recursively or not |
When the change fail
chown(string|\Symfony\Component\Filesystem\iterable $files, string $user, boolean $recursive = false)
Change the owner of an array of files or directories.
string|\Symfony\Component\Filesystem\iterable | $files | A filename, an array of files, or a \Traversable instance to change owner |
string | $user | The new owner user name |
boolean | $recursive | Whether change the owner recursively or not |
When the change fail
chgrp(string|\Symfony\Component\Filesystem\iterable $files, string $group, boolean $recursive = false)
Change the group of an array of files or directories.
string|\Symfony\Component\Filesystem\iterable | $files | A filename, an array of files, or a \Traversable instance to change group |
string | $group | The group name |
boolean | $recursive | Whether change the group recursively or not |
When the change fail
rename(string $origin, string $target, boolean $overwrite = false)
Renames a file or a directory.
string | $origin | The origin filename or directory |
string | $target | The new filename or directory |
boolean | $overwrite | Whether to overwrite the target if it already exists |
When target file or directory already exists
When origin cannot be renamed
symlink(string $originDir, string $targetDir, boolean $copyOnWindows = false)
Creates a symbolic link or copy a directory.
string | $originDir | The origin directory path |
string | $targetDir | The symbolic link name |
boolean | $copyOnWindows | Whether to copy files if on Windows |
When symlink fails
hardlink(string $originFile, string|array<mixed,string> $targetFiles)
Creates a hard link, or several hard links to a file.
string | $originFile | The original file |
string|array<mixed,string> | $targetFiles | The target file(s) |
When original file is missing or not a file
When link fails, including if link already exists
readlink(string $path, boolean $canonicalize = false) : string|null
Resolves links in paths.
With $canonicalize = false (default)
With $canonicalize = true
string | $path | A filesystem path |
boolean | $canonicalize | Whether or not to return a canonicalized path |
makePathRelative(string $endPath, string $startPath) : string
Given an existing path, convert it to a path relative to a given starting path.
string | $endPath | Absolute path of target |
string | $startPath | Absolute path where traversal begins |
Path of target relative to starting path
mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = array())
Mirrors a directory to another.
Copies files and directories from the origin directory into the target directory. By default:
override
option)delete
option)string | $originDir | The origin directory |
string | $targetDir | The target directory |
\Traversable | $iterator | Iterator that filters which files and directories to copy |
array | $options | An array of boolean options Valid options are:
|
When file type is unknown
tempnam(string $dir, string $prefix) : string
Creates a temporary file with support for custom stream wrappers.
string | $dir | The directory where the temporary filename will be created |
string | $prefix | The prefix of the generated temporary filename Note: Windows uses only the first three characters of prefix |
The new temporary filename (with path), or throw an exception on failure