From e94ea4c89bd0b79b97223de514e375f3c98d4947 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Mon, 25 Jun 2007 12:58:00 +0000 Subject: [PATCH] Good old PHP 5, and the $recursive parameter to mkdir() --- includes/GlobalFunctions.php | 42 ++---------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 27fc28ddb0..d1aac27c8d 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1663,47 +1663,9 @@ function wfTempDir() { * Make directory, and make all parent directories if they don't exist */ function wfMkdirParents( $fullDir, $mode = 0777 ) { - if ( strval( $fullDir ) === '' ) { + if( strval( $fullDir ) === '' ) return true; - } - - # Go back through the paths to find the first directory that exists - $currentDir = $fullDir; - $createList = array(); - while ( strval( $currentDir ) !== '' && !file_exists( $currentDir ) ) { - # Strip trailing slashes - $currentDir = rtrim( $currentDir, '/\\' ); - - # Add to create list - $createList[] = $currentDir; - - # Find next delimiter searching from the end - $p = max( strrpos( $currentDir, '/' ), strrpos( $currentDir, '\\' ) ); - if ( $p === false ) { - $currentDir = false; - } else { - $currentDir = substr( $currentDir, 0, $p ); - } - } - - if ( count( $createList ) == 0 ) { - # Directory specified already exists - return true; - } elseif ( $currentDir === false ) { - # Went all the way back to root and it apparently doesn't exist - return false; - } - - # Now go forward creating directories - $createList = array_reverse( $createList ); - foreach ( $createList as $dir ) { - # use chmod to override the umask, as suggested by the PHP manual - if ( !mkdir( $dir, $mode ) || !chmod( $dir, $mode ) ) { - wfDebugLog( 'mkdir', "Unable to create directory $dir\n" ); - return false; - } - } - return true; + return mkdir( $fullDir, $mode, true ); } /** -- 2.20.1