final class DirectoryManager implements DirectoryManagerInterface (View source)

Methods

void
create(string $pathIterator, int $mode = 0775)

Creates a directory including any missing parent directories.

void
void
copy(string $src, string $dst, bool $overwrite = false)

Copies a file or directory to the target path.

void
void
write(string $file, string $data, int|null $mode = 0666)

Writes data to a file and creates the target directory if needed.

void
void
delete(string $path)

Deletes a file, symbolic link, or directory.

void
stream(string $path, bool $recursive = false)

Vrací lazy seznam položek adresáře (název => absolutní cesta).

tree(string $path, bool $recursive = true)

Prochází adresář (rekurzivně nebo jen první úroveň) a vrací SplFileInfo objekty.

find(string $pattern, string $path)

Vyhledá soubory podle vzoru v daném adresáři (neprobíhá rekurze).

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.

Parameters

string $pathIterator
int $mode

Return Value

void

Exceptions

FilesystemException

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.

Parameters

string $src
string $dst
bool $overwrite

Return Value

void

Exceptions

FilesystemException

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.

Parameters

string $file
string $data
int|null $mode

Return Value

void

Exceptions

FilesystemException

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.

Parameters

string $path

Return Value

void

Exceptions

FilesystemException

stream

Generator stream(string $path, bool $recursive = false)

Vrací lazy seznam položek adresáře (název => absolutní cesta).

Parameters

string $path
bool $recursive

Return Value

Generator

Exceptions

FilesystemException

tree

Generator tree(string $path, bool $recursive = true)

Prochází adresář (rekurzivně nebo jen první úroveň) a vrací SplFileInfo objekty.

Parameters

string $path
bool $recursive

Return Value

Generator

Exceptions

FilesystemException

find

Generator find(string $pattern, string $path)

Vyhledá soubory podle vzoru v daném adresáři (neprobíhá rekurze).

Parameters

string $pattern
string $path

Return Value

Generator

Exceptions

FilesystemException