- ⌂ util
- Static Methods
\io_comand_file\util
Class with methods to simplify working with files.
Example
$filename = 'dir/sub_dir/test.txt';
// create a file and any directories that do not exist in the path
$ok = \io_comand_file\util\file_put_contents($filename, '123');
if(!$ok) {
\comand::log_error("Could not create file: $filename");
}
// recursively delete all subfolders and files of a directory
try {
\io_comand_file\util\empty_directory('dir');
} catch(\exception $e) {
\comand::log_error("Could not delete dir: " . $e->getMessage());
}
// recursively delete a directory under webCOMAND's Files path
try {
\io_comand_file\util\delete('dir');
} catch(\exception $e) {
\comand::log_error("Could not delete dir: " . $e->getMessage());
}