Universeorange.com/Docs/

R3m/framework Features Dir class

The Dir class has these methods.

Methods:

Change

Dir::change($dir);

Changes the current working directory to $dir.
If the directory doesn't exist, it creates it. It returns the old working directory.

Create

Dir::create($url='', $chmod='');

Creates a directory. if $chmod is empty, the default $chmod is used: 0740;

Exist

Dir::exist($url='');

Checks if the directory exist as a directory.

Is

Dir::is($url='');

Checks if the given $url is of type Dir.

Size

Dir::size($url='', $recursive=true);

Calculates the directory size.

Name

Dir::name($url='', $levels=null);

Give the directory name of the url.

Copy

Dir::copy($source='', $target='');

Copies a directory from $source to $target

Move

Dir::move($source='', $destination='', $overwrite=false);

Moves a directory from $source to $destination.
If $destination exists, you can use the $overwrite parameter.

Remove

Dir::remove($dir='');

Method 1 of removing a directory (using shell rm command).

Ucfirst

Dir::ucfirst($dir='');

Changes the whole directory to Capitals on the first letter of the (sub-) directory.

Read

$dir = new Dir();
$read = $dir->read($url='', $recursive=false, $format='flat');

To read a directory. You can add recursive true, to include subdirectories.
If you want a nested set, the format can change to: recursive.

Ignore

$array = [];
$array[] = 'test.txt';
$dir = new Dir();
$dir->ignore($array);
$read = $dir->read($url='', $recursive=false, $format='flat');

To ignore files in a read, use an array and the ignore method.

Delete

$dir = new Dir();
$read = $dir->delete($url='');

Method 2 of deleting a directory (using unlink).

Last modified: 2021-06-07

© 2021 universeorange.com