class Filesystem (View source)

Class Filesystem

Methods

static bool
copy(string $src, string $dest, bool $force = false)

copy

static bool
move(string $src, string $dest, bool $force = false)

move

static bool
delete(string $path)

delete

files(string $path, bool $recursive = false, bool $toArray = false)

files

folders(string $path, bool $recursive = false, boolean $toArray = false)

folders

items(string $path, bool $recursive = false, boolean $toArray = false)

items

static SplFileInfo
findOne(string $path, mixed $condition, boolean $recursive = false)

Find one file and return.

find(string $path, mixed $condition, boolean $recursive = false, boolean $toArray = false)

Find all files which matches condition.

findByCallback(string $path, Closure $callback, boolean $recursive = false, boolean $toArray = false)

Using a closure function to filter file.

createIterator(string $path, boolean $recursive = false, integer $options = null)

Create file iterator of current dir.

static array
iteratorToArray(Traversable $iterator)

iteratorToArray

Details

at line line 35
static bool copy(string $src, string $dest, bool $force = false)

copy

Parameters

string $src
string $dest
bool $force

Return Value

bool

at line line 58
static bool move(string $src, string $dest, bool $force = false)

move

Parameters

string $src
string $dest
bool $force

Return Value

bool

at line line 79
static bool delete(string $path)

delete

Parameters

string $path

Return Value

bool

at line line 102
static CallbackFilterIterator files(string $path, bool $recursive = false, bool $toArray = false)

files

Parameters

string $path
bool $recursive
bool $toArray

Return Value

CallbackFilterIterator

at line line 130
static CallbackFilterIterator folders(string $path, bool $recursive = false, boolean $toArray = false)

folders

Parameters

string $path
bool $recursive
boolean $toArray

Return Value

CallbackFilterIterator

at line line 173
static CallbackFilterIterator items(string $path, bool $recursive = false, boolean $toArray = false)

items

Parameters

string $path
bool $recursive
boolean $toArray

Return Value

CallbackFilterIterator

at line line 225
static SplFileInfo findOne(string $path, mixed $condition, boolean $recursive = false)

Find one file and return.

Parameters

string $path The directory path.
mixed $condition Finding condition, that can be a string, a regex or a callback function. Callback example: function($current, $key, $iterator) { return @preg_match('^Foo', $current->getFilename()) && ! $iterator->isDot(); }
boolean $recursive True to resursive.

Return Value

SplFileInfo Finded file info object.

at line line 253
static CallbackFilterIterator find(string $path, mixed $condition, boolean $recursive = false, boolean $toArray = false)

Find all files which matches condition.

Parameters

string $path The directory path.
mixed $condition Finding condition, that can be a string, a regex or a callback function. Callback example: function($current, $key, $iterator) { return @preg_match('^Foo', $current->getFilename()) && ! $iterator->isDot(); }
boolean $recursive True to resursive.
boolean $toArray True to convert iterator to array.

Return Value

CallbackFilterIterator Found files or paths iterator.

at line line 316
static CallbackFilterIterator findByCallback(string $path, Closure $callback, boolean $recursive = false, boolean $toArray = false)

Using a closure function to filter file.

Reference: http://www.php.net/manual/en/class.callbackfilteriterator.php

Parameters

string $path The directory path.
Closure $callback A callback function to filter file.
boolean $recursive True to recursive.
boolean $toArray True to convert iterator to array.

Return Value

CallbackFilterIterator Filtered file or path iteator.

at line line 338
static FilesystemIterator|RecursiveIteratorIterator createIterator(string $path, boolean $recursive = false, integer $options = null)

Create file iterator of current dir.

Parameters

string $path The directory path.
boolean $recursive True to recursive.
integer $options FilesystemIterator Flags provides which will affect the behavior of some methods.

Return Value

FilesystemIterator|RecursiveIteratorIterator File & dir iterator.

Exceptions

InvalidArgumentException

at line line 371
static array iteratorToArray(Traversable $iterator)

iteratorToArray

Parameters

Traversable $iterator

Return Value

array