DirectoryManager
final class DirectoryManager implements DirectoryManagerInterface (View source)
Methods
Creates a directory including any missing parent directories.
Copies a file or directory to the target path.
Writes data to a file and creates the target directory if needed.
Deletes a file, symbolic link, or directory.
Vrací lazy seznam položek adresáře (název => absolutní cesta).
Prochází adresář (rekurzivně nebo jen první úroveň) a vrací SplFileInfo objekty.
Details
create
void
create(string $pathIterator, int $mode = 0775)
Creates a directory including any missing parent directories.
The operation is idempotent: if the directory already exists, the method does nothing.
copy
void
copy(string $src, string $dst, bool $overwrite = false)
Copies a file or directory to the target path.
Directories are copied recursively. If overwrite is disabled and the target path already exists, an exception is thrown.
write
void
write(string $file, string $data, int|null $mode = 0666)
Writes data to a file and creates the target directory if needed.
If the file already exists, its contents are replaced. The mode parameter controls the resulting file permissions; null skips the chmod operation.
delete
void
delete(string $path)
Deletes a file, symbolic link, or directory.
If the path is a directory, its contents are removed recursively. If the path does not exist, the method does nothing.
stream
Generator
stream(string $path, bool $recursive = false)
Vrací lazy seznam položek adresáře (název => absolutní cesta).
tree
Generator
tree(string $path, bool $recursive = true)
Prochází adresář (rekurzivně nebo jen první úroveň) a vrací SplFileInfo objekty.
find
Generator
find(string $pattern, string $path)
Vyhledá soubory podle vzoru v daném adresáři (neprobíhá rekurze).