Dotclear 2.25
|
Files management class. More...
Public Member Functions | |
__construct (?string $root, ?string $root_url='') | |
chdir (?string $dir) | |
getPwd () | |
writable () | |
addExclusion ($list) | |
inFiles (string $file) | |
getDir () | |
getRootDirs () | |
uploadFile (string $tmp, string $dest, bool $overwrite=false) | |
uploadBits (string $name, string $bits) | |
makeDir (?string $name) | |
moveFile (?string $src_path, ?string $dst_path) | |
removeItem (?string $name) | |
removeFile (?string $file) | |
removeDir (?string $directory) | |
Data Fields | |
$root | |
$root_url | |
$dir | |
Protected Member Functions | |
isExclude (string $path) | |
isFileExclude (string $file) | |
inJail (string $path) | |
sortHandler (fileItem $a, fileItem $b) | |
Protected Attributes | |
$pwd | |
$exclude_list = [] | |
$exclude_pattern = '' | |
Files management class.
__construct | ( | ?string | $root, |
?string | $root_url = '' |
||
) |
Constructor
New filemanage istance. Note that filemanage is a jail in given root path. You won't be able to access files outside $root
path with the object's methods.
string | $root | Root path |
string | $root_url | Root URL |
References $root, $root_url, and path\real().
chdir | ( | ?string | $dir | ) |
Change directory
Changes working directory. $dir is relative to instance $root
directory.
string | $dir | Directory |
Reimplemented in dcMedia.
References $dir, path\clean(), isExclude(), and path\real().
getPwd | ( | ) |
writable | ( | ) |
Current directory is writable
addExclusion | ( | $list | ) |
Add exclusion
Appends an exclusion to exclusions list. $f should be a regexp.
array | string | $list | Exclusion regexp |
References path\real().
Referenced by dcMedia\__construct().
|
protected |
Path is excluded
Returns true if path (file or directory) $path is excluded. $path is relative to $root
path.
string | $path | Path to match |
|
protected |
File is excluded
Returns true if file $file is excluded. $file is relative to $root
path.
string | $file | File to match |
Referenced by dcMedia\fileRecord(), getDir(), dcMedia\updateFile(), uploadBits(), and uploadFile().
|
protected |
Item in jail
Returns true if file or directory $path is in jail (ie. not outside the $root
directory).
string | $path | Path to match |
References path\real().
Referenced by getDir(), moveFile(), removeDir(), removeFile(), uploadBits(), and uploadFile().
inFiles | ( | string | $file | ) |
File in files
Returns true if file $file is in files array of $dir
.
string | $file | File to match |
Referenced by dcMedia\getDir().
getDir | ( | ) |
Directory list
Creates list of items in working directory and append it to $dir
Uses sortHandler(), fileItem
References $dir, path\clean(), inJail(), isExclude(), and isFileExclude().
getRootDirs | ( | ) |
Root directories
Returns an array of directory under $root
directory.
Uses fileItem
References files\getDirList().
uploadFile | ( | string | $tmp, |
string | $dest, | ||
bool | $overwrite = false |
||
) |
Upload file
Move $tmp file to its final destination $dest and returns the destination file path.
$dest should be in jail. This method will throw exception if the file cannot be written.
You should first verify upload status, with files::uploadStatus()
or PHP native functions.
string | $tmp | Temporary uploaded file path |
string | $dest | Destination file |
bool | $overwrite | Overwrite mode |
References path\clean(), files\inheritChmod(), inJail(), isFileExclude(), and path\real().
uploadBits | ( | string | $name, |
string | $bits | ||
) |
Upload file by bits
Creates a new file $name with contents of $bits and return the destination file path.
$name should be in jail. This method will throw exception if file cannot be written.
string | $name | Destination file |
string | $bits | Destination file content |
Reimplemented in dcMedia.
References path\clean(), files\inheritChmod(), inJail(), isFileExclude(), and path\real().
makeDir | ( | ?string | $name | ) |
New directory
Creates a new directory relative to working directory.
string | $name | Directory name |
Reimplemented in dcMedia.
References path\clean(), and files\makeDir().
moveFile | ( | ?string | $src_path, |
?string | $dst_path | ||
) |
Move file
Moves a file to a new destination. Both paths are relative to $root
.
string | $src_path | Source file path |
string | $dst_path | Destination file path |
References path\clean(), inJail(), and path\real().
Referenced by dcMedia\updateFile().
removeItem | ( | ?string | $name | ) |
Remove item
Removes a file or directory which is relative to working directory.
string | $name | Item to remove |
References path\clean(), path\real(), removeDir(), and removeFile().
removeFile | ( | ?string | $file | ) |
Remove item
Removes a file which is relative to working directory.
string | $file | File to remove |
Reimplemented in dcMedia.
References path\clean(), inJail(), files\isDeletable(), and path\real().
Referenced by removeItem().
removeDir | ( | ?string | $directory | ) |
Remove item
Removes a directory which is relative to working directory.
string | $directory | Directory to remove |
Reimplemented in dcMedia.
References path\clean(), inJail(), files\isDeletable(), and path\real().
Referenced by removeItem().
$root |
Referenced by __construct(), and dcMedia\__construct().
$root_url |
Referenced by __construct(), and dcMedia\__construct().
|
protected |
Referenced by dcMedia\breadCrumb(), getPwd(), dcMedia\rebuild(), dcMedia\rebuildDB(), and dcMedia\rebuildThumbnails().
|
protected |
|
protected |
$dir |
Referenced by dcMedia\chdir(), chdir(), dcMedia\getDBDirs(), dcMedia\getDir(), getDir(), dcMedia\rebuild(), and dcMedia\rebuildThumbnails().