Commit 8d9b20d1 authored by Stefan Galinski's avatar Stefan Galinski

[BUGFIX] Usage of mkdir instead of mkdir_deep from TYPO3 (permisssions)

parent fe2307ce
......@@ -96,13 +96,13 @@ class SgLib {
/**
* deletes given files
*
* @throws Exception raised, if some files cant be deleted (thrown after deletion of all)
* @param array $files files
* @return void
* @throws Exception raised, if some files cant be deleted (thrown after deletion of all)
*/
public static function deleteFiles($files) {
// delete all old files
$error = array();
$error = [];
foreach ($files as $file) {
if (is_file($file)) {
if (!unlink($file)) {
......@@ -119,23 +119,25 @@ class SgLib {
/**
* Creates a full path (all nonexistent directories will be created)
*
* @throws Exception raised if some path token cant be created
* @param string $path full path
* @param string $protectArea protected path (i.e. /var/www -- needed for basedir restrictions)
* @return void
* @throws Exception raised if some path token cant be created
*/
public static function createDir($path, $protectArea) {
if (!is_dir($path)) {
$path = explode('/', SgLib::trimPath($protectArea, $path));
$pathAsArray = explode('/', self::trimPath($protectArea, $path));
$tmp = '';
foreach ($path as $dir) {
foreach ($pathAsArray as $dir) {
$tmp .= $dir . '/';
if (is_dir($protectArea . $tmp)) {
continue;
}
if (!mkdir($protectArea . $tmp)) {
throw new Exception('path "' . $protectArea . $tmp . '" cant be deleted');
$concurrentDirectory = $protectArea . $tmp;
GeneralUtility::mkdir_deep($concurrentDirectory);
if (!is_dir($concurrentDirectory)) {
throw new Exception('path "' . $protectArea . $tmp . '" can\'t be created.');
}
}
}
......@@ -144,9 +146,9 @@ class SgLib {
/**
* deletes a directory (all subdirectories and files will be deleted)
*
* @throws Exception raised if a file or directory cant be deleted
* @param string $path full path
* @return void
* @throws Exception raised if a file or directory cant be deleted
*/
public static function deleteDir($path) {
if (!$dh = @opendir($path)) {
......@@ -179,15 +181,15 @@ class SgLib {
/**
* searches defined files in a given path recursively
*
* @throws Exception raised if the search directory cant be read
* @param string $path search in this path
* @param string $searchRegex optional: regular expression for files
* @param integer $pathDepth optional: current path depth level (max 9)
* @return array
* @throws Exception raised if the search directory cant be read
*/
public static function searchFiles($path, $searchRegex = '', $pathDepth = 0) {
// endless recursion protection
$fileArray = array();
$fileArray = [];
if ($pathDepth >= 9) {
return $fileArray;
}
......@@ -341,5 +343,3 @@ class SgLib {
}
}
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment