Added wfMkdirParents(), used in HTML dump. Works like unix mkdir -p
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 28 May 2005 07:03:29 +0000 (07:03 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 28 May 2005 07:03:29 +0000 (07:03 +0000)
includes/GlobalFunctions.php

index cedb80b..f0f58f9 100644 (file)
@@ -1287,4 +1287,22 @@ function wfTempDir() {
        return '/tmp';
 }
 
+/**
+ * Make directory, and make all parent directories if they don't exist
+ */
+function wfMkdirParents( $fullDir, $mode ) {
+       $parts = explode( '/', $fullDir );
+       $path = '';
+       $success = false;
+       foreach ( $parts as $dir ) {
+               $path .= $dir . '/';
+               if ( !is_dir( $path ) ) {
+                       if ( !mkdir( $path, $mode ) ) {
+                               return false;
+                       }
+               }
+       }
+       return true;
+}
+
 ?>