mirror of
https://github.com/avecms/AVE.cms.git
synced 2026-08-01 08:45:44 +00:00
1023 B
1023 B
Dir - directories
App\Helpers\Dir - operations with directories.
use App\Helpers\Dir;
Methods
###create($dir, $chmod = 0775)
Create a directory recursively (like mkdir -p).
Dir::create(BASEPATH . '/uploads/2026/07');
exists($dir) / writable($path) / checkPerm($dir)
Exists/writable/permissions check.
###scan($dir)
List of directory contents.
foreach (Dir::scan($dir) as $entry) { ... }
###size($path)
Total directory size in bytes (for display - via Number::formatSize()).
echo Number::formatSize(Dir::size($uploads)); // '250 МБ'
copy($src, $dst) - recursive copying.
delete($dir) - delete the directory with all contents (carefully).
Recipes
Guarantee directory before writing file:
$dir = dirname($path);
if (!Dir::exists($dir)) { Dir::create($dir); }
File::putAtomic($path, $content);
⚠️
Dir::delete()recursively deletes everything inside - check the path before calling it.