constructor
List of parameters:
Name |
Type |
Description |
$path |
string |
|
Description:
Create a new instance of this class.
copy the directory to some destination
bool
copy
(
string $destDir, [bool $overwrite = true], [int $mode = 766], [bool $copySubDirs = false], [string $fileFilter = null], [string $dirFilter = null], [bool $useRegExp = false]
)
List of parameters:
Name |
Type |
Description |
$destDir |
string |
destination to copy the file to |
$overwrite |
bool |
setting this to false will prevent existing files from getting overwritten |
$mode |
int |
the access restriction that applies to the copied file, defaults to 0766 |
$copySubDirs |
bool |
setting this to true will cause sub-directories to be copied as well |
$fileFilter |
string |
use this to limit the copied files to a specific extension |
$dirFilter |
string |
use this to limit the copied directories to those matching the filter |
$useRegExp |
bool |
set this to bool(true) if you want filters to be treated as a regular expression |
Description:
This will create a copy of this directory and its contents on the filesystem. Bool(true) will be returned on success and bool(false) on error.
Since version 2.9.6 you can also use this function with some regular expression. To do so, set $useRegExp to bool(true). It defaults to bool(false). See the PHP manual at php.net/docs for an in-depth introduction on the use of regular expressions.
If you don't want to use regular expressions, you may still use the following wildcards for file- and directory patterns:
- ? = match 1 symbol, example: f?o, matches 'foo', as well as 'fao'
- * = match any symbols, example: *foo*, matches 'foo', or 'foobar', or 'barfoo', or 'barfoobar'
- | = seperate 2 choices, example: foo|bar, matches either 'foo', or 'bar' (but NOT 'foobar')
See the following examples:
// copy directory foo/ to destination bar/
// try to copy to bar2/ but don't overwrite if it already exists
$dir->copy('bar2/', false);
// copy again and make files write- and executeable
$dir->copy('bar3/', true, 777);
// copy to bar4/ and recurse sub-dirs
$dir->copy('bar4/', true, 766, true);
// copy all *.xml and *.xhtml files to bar3/
$dir->copy('bar5/', true, 766, true, '*.xml|*.xhtml');
// copy all sub-directories, whose names end with 'bar/'
$dir->copy('bar6/', true, 766, true, null, '*bar');
// copy all but directory 'foobar/' (use regular expression)
$dir->copy('bar7/', true, 766, true, null, '/^(?!foobar$)/i', true);
create this directory
bool
create
(
[int $mode = 777]
)
List of parameters:
Name |
Type |
Description |
$mode |
int |
access mode |
Description:
Tries to create the directory. Check the developer's cookbook for an example to this function.
remove this directory
bool
delete
(
[bool $isRecursive = false]
)
List of parameters:
Name |
Type |
Description |
$isRecursive |
bool |
triggers wether to remove directories even if they are not empty, default = false |
Description:
By option you may choose to also recursivly remove all files and subdirectories inside. Otherwise the directory will only be removed if it is empty.
Returns bool(true) on success and bool(false) on error.
list contents of a directory
array
dirlist
(
string $filter
)
List of parameters:
Name |
Type |
Description |
$filter |
string |
|
Description:
The argument $filter may contain multiple file extension, use a pipe '|' sign to seperate them. Example: "*.xml|*.html" will find all xml- and html-files
check if directory exists and is readable
bool
exists
()
Description:
return list of files within the directory
array
get
()
Description:
get size of directory
int|bool(false)
getSize
(
[string $directory = null], [bool $copySubDirs = true], [bool $useCache = true]
)
List of parameters:
Name |
Type |
Description |
$directory |
string |
directory name |
$copySubDirs |
bool |
on / off |
$useCache |
bool |
on / off |
Description:
Returns the size of $directory in bytes.
This function gets the sum of the sizes of all files in a directory.
If $directory is not provided or NULL, the current directory is used. If $copySubDirs is not provided or true, the result will include all subdirectories.
If $useCache is not provided or true, the result is cached for the current directory.
Returns bool(false) if the directory does not exist and issues an E_USER_WARNING.
check wether the directory has no contents
bool
isEmpty
()
Description:
Returns bool(true) if there are no files that match the current filter and bool(false) if there is at least 1 file that matches.
get the number of files inside the directory
int
length
()
Description:
This returns a positive integer. Note that this functions counts the files in respect to the currently set file filter. So the number of files reported here and the number in total may vary.
read contents and put results in cache (filter settings will be applied)
bool
read
()
Description:
return a string representation of this directory
string
toString
()
Description:
Returns a string with the contents of this directory. Entries are seperated by line-breaks.
Redefinition of: Object::toString()
inherited from base classes
Inherited From FileSystemResource
Inherited From Object