From: Tim Starling Date: Sat, 28 May 2005 07:03:29 +0000 (+0000) Subject: Added wfMkdirParents(), used in HTML dump. Works like unix mkdir -p X-Git-Tag: 1.5.0alpha2~68 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=95d23fe4fe12cbded70367a4a5709f1ab85cff70;p=lhc%2Fweb%2Fwiklou.git Added wfMkdirParents(), used in HTML dump. Works like unix mkdir -p --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index cedb80bc97..f0f58f9a4d 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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; +} + ?>