Skip to content

Commit 71009b8

Browse files
committed
add new methods for create dir
Signed-off-by: inhere <[email protected]>
1 parent 8f22291 commit 71009b8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/OS.php

+18
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
use function getenv;
1717
use function getmyuid;
1818
use function in_array;
19+
use function is_dir;
20+
use function is_writable;
21+
use function mkdir;
1922
use function php_uname;
2023
use function posix_getuid;
2124
use function putenv;
@@ -287,4 +290,19 @@ public static function isInteractive($fileDescriptor): bool
287290
{
288291
return function_exists('posix_isatty') && @posix_isatty($fileDescriptor);
289292
}
293+
294+
/**
295+
* Support the creation of hierarchical directories
296+
*
297+
* @param string $path
298+
* @param int $mode
299+
* @param bool $recursive
300+
*
301+
* @return bool
302+
*/
303+
public static function mkdir(string $path, int $mode = 0775, bool $recursive = true): bool
304+
{
305+
return (is_dir($path) || !(!@mkdir($path, $mode, $recursive) && !is_dir($path))) && is_writable($path);
306+
}
307+
290308
}

0 commit comments

Comments
 (0)