Class Filesystem
This provides convenience wrappers around common filesystem queries.
This is an internal helper class that should not be used in application code as it provides no guarantee for compatibility.
Constants
- 
          
          stringTYPE_DIR ¶'dir'Directory type constant 
Method Summary
- 
          copyDir() publicCopies directory with all it's contents. 
- 
          deleteDir() publicDelete directory along with all it's contents. 
- 
          dumpFile() publicDump contents to file. 
- 
          filterIterator() protectedWrap iterator in additional filtering iterator. 
- 
          find() publicFind files / directories (non-recursively) in given directory path. 
- 
          findRecursive() publicFind files/ directories recursively in given directory path. 
- 
          isStream() publicCheck whether the given path is a stream path. 
- 
          mkdir() publicCreate directory. 
Method Detail
copyDir() ¶ public
copyDir(string $source, string $destination): boolCopies directory with all it's contents.
Parameters
- 
                string$source
- Source path. 
- 
                string$destination
- Destination path. 
Returns
booldeleteDir() ¶ public
deleteDir(string $path): boolDelete directory along with all it's contents.
Parameters
- 
                string$path
- Directory path. 
Returns
boolThrows
Cake\Core\Exception\CakeExceptionIf path is not a directory.
dumpFile() ¶ public
dumpFile(string $filename, string $content): voidDump contents to file.
Parameters
- 
                string$filename
- File path. 
- 
                string$content
- Content to dump. 
Returns
voidThrows
Cake\Core\Exception\CakeExceptionWhen dumping fails.
filterIterator() ¶ protected
filterIterator(Iterator $iterator, mixed $filter): IteratorWrap iterator in additional filtering iterator.
Parameters
- 
                Iterator$iterator
- Iterator 
- 
                mixed$filter
- Regex string or callback. 
Returns
Iteratorfind() ¶ public
find(string $path, mixed $filter = null, int|null $flags = null): IteratorFind files / directories (non-recursively) in given directory path.
Parameters
- 
                string$path
- Directory path. 
- 
                mixed$filter optional
- If string will be used as regex for filtering using - RegexIterator, if callable will be as callback for- CallbackFilterIterator.
- 
                int|null$flags optional
- Flags for FilesystemIterator::__construct(); 
Returns
IteratorfindRecursive() ¶ public
findRecursive(string $path, mixed $filter = null, int|null $flags = null): IteratorFind files/ directories recursively in given directory path.
Parameters
- 
                string$path
- Directory path. 
- 
                mixed$filter optional
- If string will be used as regex for filtering using - RegexIterator, if callable will be as callback for- CallbackFilterIterator. Hidden directories (starting with dot e.g. .git) are always skipped.
- 
                int|null$flags optional
- Flags for FilesystemIterator::__construct(); 
Returns
IteratorisStream() ¶ public
isStream(string $path): boolCheck whether the given path is a stream path.
Parameters
- 
                string$path
- Path. 
Returns
boolmkdir() ¶ public
mkdir(string $dir, int $mode = 0755): voidCreate directory.
Parameters
- 
                string$dir
- Directory path. 
- 
                int$mode optional
- Octal mode passed to mkdir(). Defaults to 0755. 
Returns
voidThrows
Cake\Core\Exception\CakeExceptionWhen directory creation fails.
