public static add_webroot ($path)
Adds the $webroot to a file/folder path, if not present. Examples:
foo.txt -> /files/foo.txt
/foo.txt -> /files/foo.txt
public static strip_webroot ($path)
Removes the $webroot from a file/folder path. Examples:
/files/foo.txt -> foo.txt
files/foo.txt -> foo.txt
public static dir ($path = '')
List all directories and files in a directory. Returns an array with 'dirs' and 'files'. Each directory has a 'name', 'path', and 'mtime'. Each file also has 'fsize'.
public static search ($query)
Search for all directories and files that match a query. Returns an array with 'dirs' and 'files'. Each directory has a 'name', 'path', and 'mtime'. Each file also has 'fsize'.
public static touch ($file)
Touch a file. If it exists, updates its modification time. If not, creates a blank file.
public static rmdir ($folder, $recursive = false)
Remove a folder. The folder must be empty, or recursive must be set to true to remove non-empty folders.
private static rmdir_recursive ($path)
Handles recursively deleting folders for FileManager::rmdir()
.
public static list_folders ($path = '')
Returns a list of folders recursively under the specified folder path.
public static verify_folder ($path, $root = false)
Verify that the specified folder is valid, and exists inside a certain root folder.
public static verify_file ($path, $root = false)
Verify that the specified file is valid, and exists inside a certain root folder.
public static verify_folder_name ($name)
Verify that a folder name contains only a-z, A-Z, 0-9, underscores, and dashes.
public static verify_file_name ($name)
Verify that a file name contains only a-z, A-Z, 0-9, underscores, dashes, and at least one dot plus a file extension.
public static prop ($file, $prop, $value)
Get or set a property for the specified file.
Can also retrieve an array of a property for a
list of files if $file
is an array.
Provides an API for managing common file operations such as listing directory contents, renaming, and deleting files. Using this class, extended file properties will be correctly re-linked to files that are renamed or moved, and file and folder names and paths will be verified to be correct.
Also note that file and folder paths are specified relative to
FileManager::root()
.Usage: