[pLog-svn] r554 - plog/trunk/class/file
subaochen at devel.plogworld.net
subaochen at devel.plogworld.net
Mon Dec 20 14:05:57 GMT 2004
Author: subaochen
Date: 2004-12-20 14:05:56 +0000 (Mon, 20 Dec 2004)
New Revision: 554
Modified:
plog/trunk/class/file/file.class.php
Log:
File::createDir now can create dir like "/a/b/c"
Modified: plog/trunk/class/file/file.class.php
===================================================================
--- plog/trunk/class/file/file.class.php 2004-12-20 05:42:11 UTC (rev 553)
+++ plog/trunk/class/file/file.class.php 2004-12-20 14:05:56 UTC (rev 554)
@@ -241,7 +241,7 @@
}
/**
- * Creates a new folder
+ * Creates a new folder
*
* @static
* @param dirName The name of the new folder
@@ -249,15 +249,30 @@
*/
function createDir( $dirName, $mode = FILE_DEFAULT_DIRECTORY_CREATION_MODE )
{
- $log =& LoggerManager::getLogger( "File::createDir" );
- $log->debug( "creating folder = $dirName with mode = $mode" );
- if( !mkdir( $dirName, $mode ))
- return false;
+
+ if(file_exists($dirName)) return true;
+
+ if(substr($dirName, strlen($dirName)-1) == DIRECTORY_SEPARATOR){
+ $dirName = substr($dirName, 0,strlen($dirName)-1);
+ }
+
+ // for example, we will create dir "/a/b/c"
+ // $firstPart = "/a/b"
+ $firstPart = substr($dirName,0,strrpos($dirName, DIRECTORY_SEPARATOR));
+
+ if(file_exists($firstPart)){
+ if(!mkdir($dirName,$mode)) return false;
+ chmod( $dirName, $mode );
+ } else {
+ File::createDir($firstPart,$mode);
+ if(!mkdir($dirName,$mode)) return false;
+ chmod( $dirName, $mode );
+ }
+
- chmod( $dirName, $mode );
-
return true;
}
+
/**
* returns a temporary filename in a pseudo-random manner
@@ -348,4 +363,4 @@
return file_exists( $fileName );
}
}
-?>
\ No newline at end of file
+?>
More information about the pLog-svn
mailing list