mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/tickme.git
synced 2026-08-19 04:23:56 +00:00
38 lines
759 B
PHP
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;
|
|
}
|
|
}
|