From 95d23fe4fe12cbded70367a4a5709f1ab85cff70 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 28 May 2005 07:03:29 +0000 Subject: [PATCH] Added wfMkdirParents(), used in HTML dump. Works like unix mkdir -p --- includes/GlobalFunctions.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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; +} + ?> -- 2.20.1