MDL-23984 using standard check_dir_exists() in extlib
authorPetr Skoda <skodak@moodle.org>
Sun, 29 Aug 2010 10:12:20 +0000 (10:12 +0000)
committerPetr Skoda <skodak@moodle.org>
Sun, 29 Aug 2010 10:12:20 +0000 (10:12 +0000)
files/externallib.php

index 2dd389e..4b1760f 100755 (executable)
@@ -207,15 +207,10 @@ class moodle_file_external extends external_api {
             throw new moodle_exception('nofile');
         }
         // saving file
-        if (!file_exists($CFG->dataroot.'/temp/wsupload')) {
-            mkdir($CFG->dataroot.'/temp/wsupload/', 0777, true);
-        }
-
-        if (is_dir($CFG->dataroot.'/temp/wsupload')) {
-            $dir = $CFG->dataroot.'/temp/wsupload/';
-        } else {
+        if (!check_dir_exists($CFG->dataroot.'/temp/wsupload')) {
             throw new moodle_exception('cannotcreatetempdir');
         }
+
         if (empty($fileinfo['filename'])) {
             $filename = uniqid('wsupload').'_'.time().'.tmp';
         } else {