Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
d8cf4dd4
Commit
d8cf4dd4
authored
11 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Patches
Plain Diff
treat non-existing files as success on delete
parent
ebec603f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_test/tests/inc/io_rmdir.test.php
+60
-0
60 additions, 0 deletions
_test/tests/inc/io_rmdir.test.php
inc/io.php
+1
-0
1 addition, 0 deletions
inc/io.php
with
61 additions
and
0 deletions
_test/tests/inc/io_rmdir.test.php
+
60
−
0
View file @
d8cf4dd4
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
inc/io.php
+
1
−
0
View file @
d8cf4dd4
...
...
@@ -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
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment