first commit
This commit is contained in:
commit
e81864e683
2984 files changed
+267797
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace HermannTelser\Zuladungsliste\Utilities;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Core\Utility\PathUtility;
|
||||
|
||||
/**
|
||||
* Class FileUtility
|
||||
*/
|
||||
class FileUtility extends AbstractUtility
|
||||
{
|
||||
/**
|
||||
* @param string $path Absolute path
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function createFolderIfNotExists(string $path)
|
||||
{
|
||||
if (!is_dir($path) && !GeneralUtility::mkdir($path)) {
|
||||
throw new \UnexpectedValueException(
|
||||
'Folder ' . self::getRelativeFolderFromAbsolutePath($path) . ' does not exists and can not be created!',
|
||||
1516373962125
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get relative path from absolute path, but don't touch if it's already a relative path
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public static function getRelativeFolderFromAbsolutePath(string $path): string
|
||||
{
|
||||
if (PathUtility::isAbsolutePath($path)) {
|
||||
$path = PathUtility::getRelativePathTo($path);
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user