mirror of
https://github.com/PGYER/codefever.git
synced 2026-05-21 09:55:44 +08:00
28 lines
619 B
PHP
Executable File
28 lines
619 B
PHP
Executable File
<?php
|
|
namespace service\Utility;
|
|
|
|
use service\Utility\UUID;
|
|
use service\Utility\Command;
|
|
|
|
class Workspace {
|
|
public static function create(string $id = NULL)
|
|
{
|
|
$id = $id ? $id : UUID::getUUID();
|
|
$dir = WORKSPACE_DIR . '/' . $id;
|
|
if (!is_dir(WORKSPACE_DIR)) {
|
|
mkdir(WORKSPACE_DIR);
|
|
}
|
|
mkdir($dir);
|
|
return $dir;
|
|
}
|
|
|
|
public static function delete(string $workspace)
|
|
{
|
|
if (stripos($workspace, WORKSPACE_DIR) !== 0) {
|
|
return FALSE;
|
|
}
|
|
return Command::run([
|
|
'rm', '-rf', $workspace
|
|
]);
|
|
}
|
|
} |