Skip to content
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