class FileSystem

File system.

Methods

bool
has(string $file)

Returns TRUE if a file exists and FALSE if not.

bool
isFile(string $file)

Returns TRUE if the provided path is a file and FALSE if not.

bool
isDirectory(string $directory)

Returns TRUE if the provided path is a directory and FALSE if not.

bool
isEmpty(string $path)

Returns TRUE if a file or directory is empty and FALSE if not.

bool
isReadable(string $file)

Returns TRUE if the file is readable and FALSE if not.

bool
isWritable(string $file)

Returns TRUE if the file or directory is writable and FALSE if not.

int
lastModified(string $file)

Returns the time (unix timestamp) the file was last modified.

int
size(string $file)

Returns the fize of the file in bytes.

string
extension(string $file)

Returns the extension of the file.

bool
rename(string $oldName, string $newName)

Renames a file or directory.

bool
remove(string $file)

Deletes the file from disk.

bool
removeDirectory(string $path)

Deletes a directory and its contents from disk.

array|false
glob(string $pattern, int $flags = 0)

Returns an array of pathnames matching the provided pattern.

string|bool
get(string $file)

Returns the contents of the file.

static int|bool
put(string $file, mixed $data, bool $lock = false)

Writes the supplied data to a file.

static int|bool
prepend(string $file, mixed $data, bool $lock = false)

Prepends the supplied data to a file.

static int|bool
append(string $file, mixed $data, bool $lock = false)

Appends the supplied data to a file.

static bool
truncate(string $file, bool $lock = false)

Truncates a file.

bool
createDirectory(string $path, int $mode = 0777, bool $recursive = false)

Creates a directory.

mixed
include(string $file)

Includes a file.

mixed
includeOnce(string $file)

Includes a file it hasn't already been included.

mixed
require(string $file)

Requires a file.

mixed
requireOnce(string $file)

Requires a file if it hasn't already been required.

info(string $file)

Returns a FileInfo object.

file(string $file, string $openMode = 'r', bool $useIncludePath = false)

Returns a SplFileObject.

Details

at line 42
bool has(string $file)

Returns TRUE if a file exists and FALSE if not.

Parameters

string $file Path to file

Return Value

bool

at line 53
bool isFile(string $file)

Returns TRUE if the provided path is a file and FALSE if not.

Parameters

string $file Path to file

Return Value

bool

at line 64
bool isDirectory(string $directory)

Returns TRUE if the provided path is a directory and FALSE if not.

Parameters

string $directory Path to directory

Return Value

bool

at line 75
bool isEmpty(string $path)

Returns TRUE if a file or directory is empty and FALSE if not.

Parameters

string $path Path to directory

Return Value

bool

at line 91
bool isReadable(string $file)

Returns TRUE if the file is readable and FALSE if not.

Parameters

string $file Path to file

Return Value

bool

at line 102
bool isWritable(string $file)

Returns TRUE if the file or directory is writable and FALSE if not.

Parameters

string $file Path to file

Return Value

bool

at line 113
int lastModified(string $file)

Returns the time (unix timestamp) the file was last modified.

Parameters

string $file Path to file

Return Value

int

at line 124
int size(string $file)

Returns the fize of the file in bytes.

Parameters

string $file Path to file

Return Value

int

at line 135
string extension(string $file)

Returns the extension of the file.

Parameters

string $file Path to file

Return Value

string

at line 147
bool rename(string $oldName, string $newName)

Renames a file or directory.

Parameters

string $oldName Old name
string $newName New name

Return Value

bool

at line 158
bool remove(string $file)

Deletes the file from disk.

Parameters

string $file Path to file

Return Value

bool

at line 169
bool removeDirectory(string $path)

Deletes a directory and its contents from disk.

Parameters

string $path Path to directory

Return Value

bool

at line 193
array|false glob(string $pattern, int $flags = 0)

Returns an array of pathnames matching the provided pattern.

Parameters

string $pattern Patern
int $flags Flags

Return Value

array|false

at line 204
string|bool get(string $file)

Returns the contents of the file.

Parameters

string $file File path

Return Value

string|bool

at line 217
static int|bool put(string $file, mixed $data, bool $lock = false)

Writes the supplied data to a file.

Parameters

string $file File path
mixed $data File data
bool $lock Acquire an exclusive write lock?

Return Value

int|bool

at line 230
static int|bool prepend(string $file, mixed $data, bool $lock = false)

Prepends the supplied data to a file.

Parameters

string $file File path
mixed $data File data
bool $lock Acquire an exclusive write lock?

Return Value

int|bool

at line 243
static int|bool append(string $file, mixed $data, bool $lock = false)

Appends the supplied data to a file.

Parameters

string $file File path
mixed $data File data
bool $lock Acquire an exclusive write lock?

Return Value

int|bool

at line 255
static bool truncate(string $file, bool $lock = false)

Truncates a file.

Parameters

string $file File path
bool $lock Acquire an exclusive write lock?

Return Value

bool

at line 268
bool createDirectory(string $path, int $mode = 0777, bool $recursive = false)

Creates a directory.

Parameters

string $path Path to directory
int $mode Mode
bool $recursive Recursive

Return Value

bool

at line 279
mixed include(string $file)

Includes a file.

Parameters

string $file Path to file

Return Value

mixed

at line 290
mixed includeOnce(string $file)

Includes a file it hasn't already been included.

Parameters

string $file Path to file

Return Value

mixed

at line 301
mixed require(string $file)

Requires a file.

Parameters

string $file Path to file

Return Value

mixed

at line 312
mixed requireOnce(string $file)

Requires a file if it hasn't already been required.

Parameters

string $file Path to file

Return Value

mixed

at line 323
FileInfo info(string $file)

Returns a FileInfo object.

Parameters

string $file Path to file

Return Value

FileInfo

at line 336
SplFileObject file(string $file, string $openMode = 'r', bool $useIncludePath = false)

Returns a SplFileObject.

Parameters

string $file Path to file
string $openMode Open mode
bool $useIncludePath Use include path?

Return Value

SplFileObject