Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 95bab29

Browse files
author
Jamie Snape
committed
Tweak temporary directory methods to support subdirectories
1 parent c01000c commit 95bab29

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

core/GlobalController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,19 +339,19 @@ public function getEnvironment()
339339
*
340340
* @return string
341341
*/
342-
protected function getDataDirectory($subdir = '')
342+
protected function getDataDirectory($subDirectory = '', $createDirectory = true)
343343
{
344-
return UtilityComponent::getDataDirectory($subdir);
344+
return UtilityComponent::getDataDirectory($subDirectory, $createDirectory);
345345
}
346346

347347
/**
348348
* get the midas temporary directory
349349
*
350350
* @return string
351351
*/
352-
protected function getTempDirectory($subdir = 'misc')
352+
protected function getTempDirectory($subDirectory = 'misc', $createDirectory = true)
353353
{
354-
return UtilityComponent::getTempDirectory($subdir);
354+
return UtilityComponent::getTempDirectory($subDirectory, $createDirectory);
355355
}
356356

357357
/** return an array of form element */

core/controllers/components/UtilityComponent.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public static function run_sql_from_file($db, $sqlfile)
341341
}
342342

343343
/** Get the data directory */
344-
public static function getDataDirectory($subdir = '')
344+
public static function getDataDirectory($subDirectory = '', $createDirectory = true)
345345
{
346346
$settingModel = MidasLoader::loadModel('Setting');
347347

@@ -359,26 +359,26 @@ public static function getDataDirectory($subdir = '')
359359
}
360360
}
361361

362-
if ($subdir == '') {
362+
if ($subDirectory == '') {
363363
$path = $dataDirectory.'/';
364364
} else {
365-
$path = $dataDirectory.'/'.$subdir.'/';
365+
$path = $dataDirectory.'/'.$subDirectory.'/';
366366
}
367367

368-
if (is_writable($dataDirectory) && !file_exists($path)) {
368+
if ($createDirectory && is_writable($dataDirectory) && !file_exists($path)) {
369369
mkdir($path, 0777, true);
370370
}
371371

372372
return realpath($path);
373373
}
374374

375375
/**
376-
* @param $subdir
376+
* @param $subDirectory
377377
* get the midas temporary directory, appending the param $subdir, which
378378
* defaults to "misc"
379379
* @return string
380380
*/
381-
public static function getTempDirectory($subdir = "misc")
381+
public static function getTempDirectory($subDirectory = 'misc', $createDirectory = true)
382382
{
383383
$settingModel = MidasLoader::loadModel('Setting');
384384

@@ -398,9 +398,9 @@ public static function getTempDirectory($subdir = "misc")
398398
}
399399
}
400400

401-
$path = $tempDirectory.'/'.$subdir;
401+
$path = $tempDirectory.'/'.$subDirectory;
402402

403-
if (is_writable($tempDirectory) && !file_exists($path)) {
403+
if ($createDirectory && is_writable($tempDirectory) && !file_exists($path)) {
404404
mkdir($path, 0777, true);
405405
}
406406

core/models/MIDASModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public function initialize()
4949
*
5050
* @return string
5151
*/
52-
protected function getTempDirectory()
52+
protected function getTempDirectory($subDirectory = 'misc', $createDirectory = true)
5353
{
54-
return UtilityComponent::getTempDirectory();
54+
return UtilityComponent::getTempDirectory($subDirectory, $createDirectory);
5555
}
5656

5757
/**

0 commit comments

Comments
 (0)