diff --git a/src/Utils/FileSystem.php b/src/Utils/FileSystem.php index 14771399f..5402d0fc8 100644 --- a/src/Utils/FileSystem.php +++ b/src/Utils/FileSystem.php @@ -24,8 +24,8 @@ class FileSystem */ public static function createDir($dir, $mode = 0777) { - if (!is_dir($dir) && !@mkdir($dir, $mode, TRUE)) { // intentionally @; not atomic - throw new Nette\IOException("Unable to create directory '$dir'."); + if (!is_dir($dir) && !@mkdir($dir, $mode, TRUE) && !is_dir($dir)) { // @ - dir may already exist + throw new Nette\IOException("Unable to create directory '$dir'. " . error_get_last()['message']); } } diff --git a/tests/Utils/FileSystem.phpt b/tests/Utils/FileSystem.phpt index 75be57c11..68a69dbe9 100644 --- a/tests/Utils/FileSystem.phpt +++ b/tests/Utils/FileSystem.phpt @@ -21,7 +21,7 @@ test(function () { // createDir Assert::exception(function () { FileSystem::createDir(''); -}, Nette\IOException::class, "Unable to create directory ''."); +}, Nette\IOException::class, "Unable to create directory ''.%A%"); test(function () { // write + read @@ -32,7 +32,7 @@ test(function () { // write + read Assert::exception(function () { FileSystem::write('', 'Hello'); -}, Nette\IOException::class, "Unable to create directory ''."); +}, Nette\IOException::class, "Unable to create directory ''.%A%"); Assert::exception(function () { FileSystem::read('');