Skip to content

Commit

Permalink
Merge d638408 into c00e843
Browse files Browse the repository at this point in the history
  • Loading branch information
stevleibelt committed Aug 28, 2014
2 parents c00e843 + d638408 commit f48207c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/docs
/nbproject
/vendor
.idea
4 changes: 4 additions & 0 deletions src/main/php/org/bovigo/vfs/vfsStreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,10 @@ public function rename($path_from, $path_to)
trigger_error('Target is not a directory', E_USER_WARNING);
return false;
}
if (!$srcContent->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
trigger_error('Permission denied', E_USER_WARNING);
return false;
}

// remove old source first, so we can rename later
// (renaming first would lead to not being able to remove the old path)
Expand Down
12 changes: 12 additions & 0 deletions src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,18 @@ public function cannotRenameToNonWritableDir()
$this->assertFalse(@rename($this->baz2URL, vfsStream::url('foo/bar/baz3')));
}

/**
* @test
*/
public function cannotRenameNotWritableFile()
{
$this->baz1->chmod(0400);
$oldName = $this->baz1->url();
$newName = $this->baz1->url() . '.new';

$this->assertFalse(@rename($oldName, $newName));
}

/**
* @test
* @group issue_38
Expand Down

0 comments on commit f48207c

Please sign in to comment.