Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
FileSystem Class Reference

Static Public Member Functions

static clearDirectory ($path, $deleteRoot=FALSE, array $omitFiles=array())
 
static listDirectory ($path, array $extensions=array(), $nested=TRUE, $fullPath=TRUE)
 
static findDirectories ($path, $name)
 
static getHashDir ($id)
 
static readableSize ($path, $unit=NULL)
 
static getBaseName ($path)
 

Data Fields

const HASH_DIR_FILE_COUNT = 10000
 
const FILE_SIZE_BYTE = 'B'
 
const FILE_SIZE_KILOBYTE = 'kB'
 
const FILE_SIZE_MEGABYTE = 'MB'
 
const FILE_SIZE_GIGABYTE = 'GB'
 

Detailed Description

Library for general file system operations.

Methods for adding, deleting and modifying directories and files should reside here.

Since
4.0.0

Definition at line 21 of file FileSystem.inc.

Member Function Documentation

static clearDirectory (   $path,
  $deleteRoot = FALSE,
array  $omitFiles = array() 
)
static

Removes a directory from the file system.

Enters subdirectories and removes all content, and deletes the parent directory if specified.

Parameters
string$pathThe path of the directory to delete.
boolean$deleteRootWhether to delete the parent directory.
array$omitFilesArray of file names that lie in the root directory that should not be deleted. Note, the $deleteRoot param should be false if this is not empty.
Since
4.0.0
Returns
boolean
Exceptions
RuntimeExceptionWhen the environment prevents the directory from being succesfully deleted.

Definition at line 60 of file FileSystem.inc.

static findDirectories (   $path,
  $name 
)
static

Recursively finds directories with the specified name.

Returns the absolute paths to the directories, starting from the specified path.

Parameters
string$pathThe path of the directory to start at.
string$nameThe name of the directories to find.
Since
4.0.0
Returns
array

Definition at line 230 of file FileSystem.inc.

static getBaseName (   $path)
static

Basename for unix and Windows.

Parameters
string$pathPath for a file.
Since
4.0.0
Returns
string

Definition at line 323 of file FileSystem.inc.

static getHashDir (   $id)
static

Returns the relative hash directory for the specified id.

Parameters
integer$idThe positive integer to return the hash dir for.
Since
4.0.0
Returns
string
Exceptions
InvalidArgumentExceptionWhen a negative $id is passed.

Definition at line 259 of file FileSystem.inc.

static listDirectory (   $path,
array  $extensions = array(),
  $nested = TRUE,
  $fullPath = TRUE 
)
static

Lists the contents of a directory.

Allows the specifying of file extensions, and whether or not to include full paths in the resulting array, or just filenames. Returns an array of file names.

Parameters
string$pathThe path of the directory to list.
array$extensionsAn array of extensions (with the leading dots) of files to return.
boolean$nestedInclude subdirectories in the listing.
boolean$fullPathInclude the full path, or just the filename.
Since
4.0.0
Returns
array

Definition at line 144 of file FileSystem.inc.

static readableSize (   $path,
  $unit = NULL 
)
static

Return the size of a file with human readable units appended.

Parameters
string$pathThe path to the file.
string$unitUnits to display file size with (see constants).
Since
4.0.0
Returns
string

Definition at line 283 of file FileSystem.inc.


The documentation for this class was generated from the following file: