Skip to content

Commit

Permalink
ensure last dir is not skipped if name is '0', fixes #131
Browse files Browse the repository at this point in the history
A check with emptyh('0') returns true, which then skips creation of the
last directory. Thus, the check must be explicitly for a string and it's
length.
  • Loading branch information
mikey179 committed Apr 9, 2016
1 parent 233f48f commit c19925c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
1.6.3 (2016-04-09)
------------------

* fixed #131 recursive mkdir() fails if the last dirname is '0'


1.6.2 (2016-01-13)
------------------

Expand Down
2 changes: 1 addition & 1 deletion src/main/php/org/bovigo/vfs/vfsStream.php
Expand Up @@ -358,7 +358,7 @@ public static function newDirectory($name, $permissions = null)
$ownName = substr($name, 0, $firstSlash);
$subDirs = substr($name, $firstSlash + 1);
$directory = new vfsStreamDirectory($ownName, $permissions);
if (!empty($subDirs)) {
if (is_string($subDirs) && strlen($subDirs) > 0) {
self::newDirectory($subDirs, $permissions)->at($directory);
}

Expand Down
13 changes: 13 additions & 0 deletions src/test/php/org/bovigo/vfs/vfsStreamWrapperDirTestCase.php
Expand Up @@ -249,6 +249,19 @@ public function mkDirShouldNotOverwriteExistingFilesAndTriggerE_USER_WARNING()
$this->assertFalse(mkdir(vfsStream::url('root/test.txt')));
}

/**
* @test
* @group issue_131
* @since 1.6.3
*/
public function allowsRecursiveMkDirWithDirectoryName0()
{
vfsStream::setup('root');
$subdir = vfsStream::url('root/a/0');
mkdir($subdir, 0777, true);
$this->assertFileExists($subdir);
}

/**
* @test
* @group permissions
Expand Down

0 comments on commit c19925c

Please sign in to comment.