bludit/bl-kernel/helpers/filesystem.class.php

61 lines
1.2 KiB
PHP
Raw Normal View History

2015-05-05 03:00:01 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
2015-03-08 18:02:59 +01:00
2015-05-31 03:06:55 +02:00
class Filesystem {
2015-03-08 18:02:59 +01:00
2015-09-20 23:46:50 +02:00
// Returns an array with the absolutes directories.
2017-06-26 22:50:56 +02:00
public static function listDirectories($path, $regex='*', $sortByDate=false)
2015-03-08 18:02:59 +01:00
{
2015-09-15 01:07:15 +02:00
$directories = glob($path.$regex, GLOB_ONLYDIR);
if(empty($directories)) {
return array();
}
2017-06-26 22:50:56 +02:00
if($sortByDate) {
usort($directories, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
}
2015-09-15 01:07:15 +02:00
return $directories;
}
2015-11-04 01:28:11 +01:00
public static function listFiles($path, $regex='*', $extension='*', $sortByDate=false)
2015-09-15 01:07:15 +02:00
{
$files = glob($path.$regex.'.'.$extension);
if(empty($files)) {
return array();
}
2015-11-04 01:28:11 +01:00
if($sortByDate) {
usort($files, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
}
2015-09-15 01:07:15 +02:00
return $files;
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02: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);
}
2017-06-29 22:13:25 +02:00
public static function fileExists($filename)
{
return file_exists($filename);
}
2016-01-12 03:18:20 +01:00
}