Files
portal/app/Classes/CodeGenerator/Utils/FileUtil.php
T
2020-09-14 16:36:40 +08:00

38 lines
759 B
PHP

<?php
namespace App\Classes\CodeGenerator\Utils;
class FileUtil
{
public static function createFile($path, $fileName, $contents)
{
if (!file_exists($path)) {
mkdir($path, 0755, true);
}
$path = $path.$fileName;
file_put_contents($path, $contents);
}
public static function createDirectoryIfNotExist($path, $replace = false)
{
if (file_exists($path) && $replace) {
rmdir($path);
}
if (!file_exists($path)) {
mkdir($path, 0755, true);
}
}
public static function deleteFile($path, $fileName)
{
if (file_exists($path.$fileName)) {
return unlink($path.$fileName);
}
return false;
}
}