Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify 'deleteRecursively' method of 'Directory' class #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ public function createRecursively($mode = null) {

/**
* Attempts to delete the directory including any contents recursively
*
* @param string the path of the directory to be removed
*/
public function deleteRecursively() {
if ($this->exists()) {
$entries = @\scandir($this->path);
public function deleteRecursively($path) {
if ( is_dir($path) ) {
$entries = @\scandir($path);

foreach ($entries as $entry) {
if ($entry !== '.' && $entry !== '..') {
$entryPath = $this->path . '/' . $entry;
$entryPath = $path . '/' . $entry;

if (@\is_dir($entryPath)) {
$this->deleteRecursively($entryPath);
Expand All @@ -101,7 +103,7 @@ public function deleteRecursively() {
}
}

@\rmdir($this->path);
@\rmdir($path);
}
}

Expand Down