method createPath documentation in bbn\File\Dir
Creates a folder with the given path.
Example
\bbn\X::dump(\bbn\File\Dir::createPath("/home/data/test/New"));
\\ (string) "/home/data/test/New"
function(string $dir, $chmod = false)
{
if ( !$dir || !\is_string($dir) ){
return null;
}
$bits = [];
//clearstatcache();
$path = self::clean($dir);
while ( $path && !is_dir($path) ){
$bits[] = X::basename($path);
$path = X::dirname($path);
}
if (is_dir($path)) {
foreach (array_reverse($bits) as $b) {
if (!empty($b)) {
$path .= '/'.$b;
if (!is_dir($path)) {
try {
mkdir($path);
}
catch (\Exception $e) {
\bbn\X::log($e->getMessage(), 'errors');
}
}
if (!is_dir($path)) {
return null;
}
if ($chmod) {
try {
chmod($path, $chmod);
}
catch (\Exception $e) {
\bbn\X::log($e->getMessage(), 'errors');
}
}
}
}
}
return $dir;
}
Creates a folder with the given path. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions