Universeorange.com/Docs/
The
Dir classhas these methods.
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.
Dir::create($url='', $chmod='');
Creates a directory. if $chmod is empty, the default $chmod is used: 0740;
Dir::exist($url='');
Checks if the directory exist as a directory.
Dir::is($url='');
Checks if the given $url is of type Dir.
Dir::size($url='', $recursive=true);
Calculates the directory size.
Dir::name($url='', $levels=null);
Give the directory name of the url.
Dir::copy($source='', $target='');
Copies a directory from $source to $target
Dir::move($source='', $destination='', $overwrite=false);
Moves a directory from $source to $destination.
If $destination exists, you can use the $overwrite parameter.
Dir::remove($dir='');
Method 1 of removing a directory (using shell rm command).
Dir::ucfirst($dir='');
Changes the whole directory to Capitals on the first letter of the (sub-) directory.
$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.
$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.
$dir = new Dir();
$read = $dir->delete($url='');
Method 2 of deleting a directory (using unlink).
Last modified: 2021-06-06
© 2021 universeorange.com