Folder
A Folder handling class
since |
1.0 |
---|
Methods
_items
Function to read the files/folders in a folder.
_items(string $path, string $filter, mixed $recurse, boolean $full, array $exclude, string $excludeFilterString, boolean $findfiles) : array
since |
1.0 |
---|
Arguments
- $path
string
The path of the folder to read.- $filter
string
A filter for file names.- $recurse
mixed
True to recursively search into sub-folders, or an integer to specify the maximum depth.- $full
boolean
True to return the full path to the file.- $exclude
array
Array with names of files which should not be shown in the result.- $excludeFilterString
string
Regexp of files to exclude- $findfiles
boolean
True to read the files, false to read the folders
Response
array
Files.
copy
Copy a folder.
copy(string $src, string $dest, string $path = '', boolean $force = false, boolean $useStreams = false) : boolean
since |
1.0 |
---|---|
throws |
|
Arguments
- $src
string
The path to the source folder.- $dest
string
The path to the destination folder.- $path
string
An optional base path to prefix to the file names.- $force
boolean
Force copy.- $useStreams
boolean
Optionally force folder/file overwrites.
Response
boolean
True on success.
create
Create a folder -- and all necessary parent folders.
create(string $path = '', integer $mode = 493) : boolean
since |
1.0 |
---|---|
throws |
|
Arguments
- $path
string
A path to create from the base path.- $mode
integer
Directory permissions to set for folders created. 0755 by default.
Response
boolean
True if successful.
delete
Delete a folder.
delete(string $path) : boolean
since |
1.0 |
---|---|
throws |
|
Arguments
- $path
string
The path to the folder to delete.
Response
boolean
True on success.
files
Utility function to read the files in a folder.
files(string $path, string $filter = '.', mixed $recurse = false, boolean $full = false, array $exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX'), array $excludeFilter = array('^\..*', '.*~')) : array
since |
1.0 |
---|---|
throws |
|
Arguments
- $path
string
The path of the folder to read.- $filter
string
A filter for file names.- $recurse
mixed
True to recursively search into sub-folders, or an integer to specify the maximum depth.- $full
boolean
True to return the full path to the file.- $exclude
array
Array with names of files which should not be shown in the result.- $excludeFilter
array
Array of filter to exclude
Response
array
Files in the given folder.
folders
Utility function to read the folders in a folder.
folders(string $path, string $filter = '.', mixed $recurse = false, boolean $full = false, array $exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX'), array $excludeFilter = array('^\..*')) : array
since |
1.0 |
---|---|
throws |
|
Arguments
- $path
string
The path of the folder to read.- $filter
string
A filter for folder names.- $recurse
mixed
True to recursively search into sub-folders, or an integer to specify the maximum depth.- $full
boolean
True to return the full path to the folders.- $exclude
array
Array with names of folders which should not be shown in the result.- $excludeFilter
array
Array with regular expressions matching folders which should not be shown in the result.
Response
array
Folders in the given folder.
listFolderTree
Lists folder in format suitable for tree display.
listFolderTree(string $path, string $filter, integer $maxLevel = 3, integer $level, integer $parent) : array
since |
1.0 |
---|
Arguments
- $path
string
The path of the folder to read.- $filter
string
A filter for folder names.- $maxLevel
integer
The maximum number of levels to recursively read, defaults to three.- $level
integer
The current level, optional.- $parent
integer
Unique identifier of the parent folder, if any.
Response
array
Folders in the given folder.
makeSafe
Makes path name safe to use.
makeSafe(string $path) : string
since |
1.0 |
---|
Arguments
- $path
string
The full path to sanitise.
Response
string
The sanitised string.
move
Moves a folder.
move(string $src, string $dest, string $path = '', boolean $useStreams = false) : string|boolean
since |
1.0 |
---|
Arguments
- $src
string
The path to the source folder.- $dest
string
The path to the destination folder.- $path
string
An optional base path to prefix to the file names.- $useStreams
boolean
Optionally use streams.
Response
string|boolean
Error message on false or boolean true on success.