Initial commit.
This commit is contained in:
38
lib/php/monica/mkalldir.inc.php
Normal file
38
lib/php/monica/mkalldir.inc.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// File name: mkalldir.inc.php
|
||||
// Description: PHP subroutine to create all components of a directory
|
||||
// Date: 2002-04-16
|
||||
// Author: imacat <imacat@pristine.com.tw>
|
||||
// Copyright: Copyright (C) 2002-2007 Pristine Communications
|
||||
|
||||
// Set the include path
|
||||
if (!defined("INCPATH_SET")) {
|
||||
require_once dirname(__FILE__) . "/incpath.inc.php";
|
||||
}
|
||||
// Referenced subroutines
|
||||
require_once "monica/rel2abs.inc.php";
|
||||
|
||||
// mkalldir: Create all the components of a directory
|
||||
// Input: Directory name $dir. It won't check at all.
|
||||
// Output: true if success, false if failed
|
||||
function mkalldir($dir)
|
||||
{
|
||||
// Standardize it
|
||||
$dir = stdpath($dir);
|
||||
// Directories to create
|
||||
$dirs = array();
|
||||
// Find all the directories to create
|
||||
while ($dir != "" && !file_exists($dir)) {
|
||||
$dirs[] = $dir;
|
||||
$dir = dirname($dir);
|
||||
}
|
||||
// Create from the last one
|
||||
for ($i = count($dirs) - 1; $i >= 0; $i--) {
|
||||
if (mkdir($dirs[$i], 0755) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user