PHP Interface FOF30\Platform\FilesystemInterface

Show file Open project: akeeba/fof

Public Methods

Method Description
__construct ( Container $c ) Public constructor.
fileCopy ( string $src, string $dest ) : boolean Copies a file
fileDelete ( mixed $file ) : boolean Delete a file or array of files
fileExists ( $path ) : boolean Does the file exists?
fileWrite ( string $file, &$buffer ) : boolean Write contents to a file
folderCreate ( string $path = '', integer $mode = 493 ) : boolean Create a folder -- and all necessary parent folders.
folderExists ( string $path ) : boolean Wrapper for the standard file_exists function
folderFiles ( string $path, string $filter = '.', mixed $recurse = false, boolean $full = false, array $exclude = ['.svn', 'CVS', '.DS_Store', '__MACOSX'], array $excludefilter = ['^\..*', '.*~'] ) : array Utility function to read the files in a folder.
folderFolders ( string $path, string $filter = '.', mixed $recurse = false, boolean $full = false, array $exclude = ['.svn', 'CVS', '.DS_Store', '__MACOSX'], array $excludefilter = ['^\..*'] ) : array Utility function to read the folders in a folder.
getExt ( string $file ) : string Gets the extension of a file name
pathCheck ( string $path ) : string Checks for snooping outside of the file system root.
pathClean ( string $path, string $ds = DIRECTORY_SEPARATOR ) : string Function to strip additional / or \ in a path name.
pathFind ( mixed $paths, string $file ) : mixed Searches the directory paths for a given file.
stripExt ( string $file ) : string Strips the last extension off of a file name

Method Details

__construct() public method

Public constructor.
public __construct ( Container $c )
$c FOF30\Container\Container The component container

fileCopy() public method

Copies a file
public fileCopy ( string $src, string $dest ) : boolean
$src string The path to the source file
$dest string The path to the destination file
return boolean True on success

fileDelete() public method

Delete a file or array of files
public fileDelete ( mixed $file ) : boolean
$file mixed The file name or an array of file names
return boolean True on success

fileExists() public method

Does the file exists?
public fileExists ( $path ) : boolean
$path string Path to the file to test
return boolean

fileWrite() public method

Write contents to a file
public fileWrite ( string $file, &$buffer ) : boolean
$file string The full file path
return boolean True on success

folderCreate() public method

Create a folder -- and all necessary parent folders.
public folderCreate ( string $path = '', integer $mode = 493 ) : boolean
$path string A path to create from the base path.
$mode integer Directory permissions to set for folders created. 0755 by default.
return boolean True if successful.

folderExists() public method

Wrapper for the standard file_exists function
public folderExists ( string $path ) : boolean
$path string Folder name relative to installation dir
return boolean True if path is a folder

folderFiles() public method

Utility function to read the files in a folder.
public folderFiles ( string $path, string $filter = '.', mixed $recurse = false, boolean $full = false, array $exclude = ['.svn', 'CVS', '.DS_Store', '__MACOSX'], array $excludefilter = ['^\..*', '.*~'] ) : array
$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
return array Files in the given folder.

folderFolders() public method

Utility function to read the folders in a folder.
public folderFolders ( string $path, string $filter = '.', mixed $recurse = false, boolean $full = false, array $exclude = ['.svn', 'CVS', '.DS_Store', '__MACOSX'], array $excludefilter = ['^\..*'] ) : array
$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.
return array Folders in the given folder.

getExt() public method

Gets the extension of a file name
public getExt ( string $file ) : string
$file string The file name
return string The file extension

pathCheck() public method

Checks for snooping outside of the file system root.
public pathCheck ( string $path ) : string
$path string A file system path to check.
return string A cleaned version of the path or exit on error.

pathClean() public method

Function to strip additional / or \ in a path name.
public pathClean ( string $path, string $ds = DIRECTORY_SEPARATOR ) : string
$path string The path to clean.
$ds string Directory separator (optional).
return string The cleaned path.

pathFind() public method

Searches the directory paths for a given file.
public pathFind ( mixed $paths, string $file ) : mixed
$paths mixed An path string or array of path strings to search in
$file string The file name to look for.
return mixed The full path and file name for the target file, or boolean false if the file is not found in any of the paths.

stripExt() public method

Strips the last extension off of a file name
public stripExt ( string $file ) : string
$file string The file name
return string The file name without the extension