2015-05-05 01:00:01 +00:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
2015-03-08 14:02:59 -03:00
|
|
|
|
2015-05-30 22:06:55 -03:00
|
|
|
class Filesystem {
|
2015-03-08 14:02:59 -03:00
|
|
|
|
2015-09-20 18:46:50 -03:00
|
|
|
// Returns an array with the absolutes directories.
|
2015-03-08 14:02:59 -03:00
|
|
|
public static function listDirectories($path, $regex='*')
|
|
|
|
{
|
2015-09-14 20:07:15 -03:00
|
|
|
$directories = glob($path.$regex, GLOB_ONLYDIR);
|
|
|
|
|
|
|
|
if(empty($directories)) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $directories;
|
|
|
|
}
|
|
|
|
|
2015-11-03 21:28:11 -03:00
|
|
|
public static function listFiles($path, $regex='*', $extension='*', $sortByDate=false)
|
2015-09-14 20:07:15 -03:00
|
|
|
{
|
|
|
|
$files = glob($path.$regex.'.'.$extension);
|
|
|
|
|
|
|
|
if(empty($files)) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2015-11-03 21:28:11 -03:00
|
|
|
if($sortByDate) {
|
|
|
|
usort($files, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
|
|
|
|
}
|
|
|
|
|
2015-09-14 20:07:15 -03:00
|
|
|
return $files;
|
2015-03-08 14:02:59 -03:00
|
|
|
}
|
|
|
|
|
2015-05-05 01:00:01 +00:00
|
|
|
public static function mkdir($pathname, $recursive=false)
|
|
|
|
{
|
|
|
|
// DEBUG: Ver permisos si son correctos
|
|
|
|
return mkdir($pathname, 0755, $recursive);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function rmdir($pathname)
|
|
|
|
{
|
|
|
|
return rmdir($pathname);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function mv($oldname, $newname)
|
|
|
|
{
|
|
|
|
return rename($oldname, $newname);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function rmfile($filename)
|
|
|
|
{
|
|
|
|
return unlink($filename);
|
|
|
|
}
|
|
|
|
|
2016-01-11 23:18:20 -03:00
|
|
|
}
|