Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
9cbf4d8d
Commit
9cbf4d8d
authored
Jun 27, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4091 from resurtm/4080-file-helper-remove-directory-symlinks
Fix possibility of non-removed symlinked directory.
parents
06f27758
9bc8c330
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
18 deletions
+15
-18
BaseFileHelper.php
framework/helpers/BaseFileHelper.php
+15
-18
No files found.
framework/helpers/BaseFileHelper.php
View file @
9cbf4d8d
...
@@ -277,32 +277,29 @@ class BaseFileHelper
...
@@ -277,32 +277,29 @@ class BaseFileHelper
*/
*/
public
static
function
removeDirectory
(
$dir
,
$options
=
[])
public
static
function
removeDirectory
(
$dir
,
$options
=
[])
{
{
if
(
!
isset
(
$options
[
'traverseSymlinks'
]))
{
if
(
!
is_dir
(
$dir
))
{
$options
[
'traverseSymlinks'
]
=
false
;
}
if
(
!
is_dir
(
$dir
)
||
!
(
$handle
=
opendir
(
$dir
)))
{
return
;
return
;
}
}
while
((
$file
=
readdir
(
$handle
))
!==
false
)
{
if
(
!
is_link
(
$dir
)
||
isset
(
$options
[
'traverseSymlinks'
])
&&
$options
[
'traverseSymlinks'
]
)
{
if
(
$file
===
'.'
||
$file
===
'..'
)
{
if
(
!
(
$handle
=
opendir
(
$dir
))
)
{
continue
;
return
;
}
}
$path
=
$dir
.
DIRECTORY_SEPARATOR
.
$file
;
while
((
$file
=
readdir
(
$handle
))
!==
false
)
{
if
(
is_link
(
$path
))
{
if
(
$file
===
'.'
||
$file
===
'..'
)
{
if
(
$options
[
'traverseSymlinks'
]
&&
is_dir
(
$path
))
{
continue
;
static
::
removeDirectory
(
$path
,
$options
);
}
}
unlink
(
$path
);
$path
=
$dir
.
DIRECTORY_SEPARATOR
.
$file
;
}
else
{
if
(
is_dir
(
$path
))
{
if
(
is_file
(
$path
))
{
unlink
(
$path
);
}
else
{
static
::
removeDirectory
(
$path
,
$options
);
static
::
removeDirectory
(
$path
,
$options
);
}
else
{
unlink
(
$path
);
}
}
}
}
closedir
(
$handle
);
}
}
closedir
(
$handle
);
if
(
is_link
(
$dir
))
{
if
(
!
is_link
(
$dir
))
{
unlink
(
$dir
);
}
else
{
rmdir
(
$dir
);
rmdir
(
$dir
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment