Skip to content
Snippets Groups Projects
Commit d8cf4dd4 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

treat non-existing files as success on delete

parent ebec603f
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,66 @@
class io_rmdir_test extends DokuWikiTest {
function test_nopes(){
// set up test dir
$dir = io_mktmpdir();
$top = dirname($dir);
$this->assertTrue($dir !== false);
$this->assertTrue(is_dir($dir));
// switch into it
$this->assertTrue(chdir($dir));
$this->assertEquals($dir, getcwd());
$this->assertFalse(io_rmdir('', false));
clearstatcache();
$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($top));
$this->assertFalse(io_rmdir('', true));
clearstatcache();
$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($top));
$this->assertFalse(io_rmdir(null, false));
clearstatcache();
$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($top));
$this->assertFalse(io_rmdir(null, true));
clearstatcache();
$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($top));
$this->assertFalse(io_rmdir(false, false));
clearstatcache();
$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($top));
$this->assertFalse(io_rmdir(false, true));
clearstatcache();
$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($top));
$this->assertFalse(io_rmdir(array(), false));
clearstatcache();
$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($top));
$this->assertFalse(io_rmdir(array(), true));
clearstatcache();
$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($top));
$this->assertFileNotExists("$dir/this/does/not/exist");
$this->assertTrue(io_rmdir("$dir/this/does/not/exist"));
clearstatcache();
$this->assertFileNotExists("$dir/this/does/not/exist");
$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($top));
}
function test_empty_single(){
// set up test dir
......
......@@ -410,6 +410,7 @@ function io_mkdir_p($target){
*/
function io_rmdir($path, $removefiles = false) {
if(!is_string($path) || $path == "") return false;
if(!file_exists($path)) return true; // it's already gone or was never there, count as success
if(is_dir($path) && !is_link($path)) {
$dirs = array();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment