You are here

public static function UtilsPHP::delete in N1ED - Visual editor as CKEditor plugin with Bootstrap support 7

3 calls to UtilsPHP::delete()
ActionUploadCancel::run in vendor/edsdk/file-uploader-server-php/src/lib/action/ActionUploadCancel.php
ActionUploadCommit::run in vendor/edsdk/file-uploader-server-php/src/lib/action/ActionUploadCommit.php
UtilsPHP::cleanDirectory in vendor/edsdk/file-uploader-server-php/src/lib/file/UtilsPHP.php

File

vendor/edsdk/file-uploader-server-php/src/lib/file/UtilsPHP.php, line 20

Class

UtilsPHP

Namespace

EdSDK\FileUploaderServer\lib\file

Code

public static function delete($dirOrFile, $deleteSelfDir = true) {
  if (is_file($dirOrFile)) {
    $result = is_dir($dirOrFile) ? rmdir($dirOrFile) : unlink($dirOrFile);
    if (!$result) {
      throw new Exception('Unable to delete file: ' . $dirOrFile);
    }
  }
  elseif (is_dir($dirOrFile)) {
    $scan = glob(rtrim($dirOrFile, '/') . '/*');
    foreach ($scan as $index => $path) {
      UtilsPHP::delete($path);
    }
    if ($deleteSelfDir) {
      if (!rmdir($dirOrFile)) {
        throw new Exception('Unable to delete directory: ' . $dirOrFile);
      }
    }
  }
}