application/Espo/Core/Utils/File/Manager.php
public function removeInDir($dirPath, $removeWithDir = false)
    {
        $fileList = $this->getFileList($dirPath, false);

        $result = true;
        if (is_array($fileList)) {
            foreach ($fileList as $file) {
                $fullPath = Utils\Util::concatPath($dirPath, $file);
                if (is_dir($fullPath)) {
                    $result &= $this->removeInDir($fullPath, true);
                } else if (file_exists($fullPath)) {
                    $result &= unlink($fullPath);
                }
            }
        }

        if ($removeWithDir && $this->isDirEmpty($dirPath)) {
            $result &= $this->rmdir($dirPath);
        }

        return (bool) $result;
    }
public function removeInDir($dirPath, $removeWithDir = false)
    {
        $fileList = $this->getFileList($dirPath, false);

        $result = true;
        if (is_array($fileList)) {
            foreach ($fileList as $file) {
                $fullPath = Utils\Util::concatPath($dirPath, $file);
                if (is_dir($fullPath)) {
                    $result &= $this->removeInDir($fullPath, true);
                } else if (file_exists($fullPath)) {
                    $result &= unlink($fullPath);
                }
            }
        }

        if ($removeWithDir && $this->isDirEmpty($dirPath)) {
            $result &= $this->rmdir($dirPath);
        }

        return (bool) $result;
    }
public function removeInDir ( $ dirPath , $ removeWithDir = false ) { $ fileList = $ this -> getFileList ( $ dirPath , false ) ; $ result = true ; if ( is_array ( $ fileList ) ) { foreach ( $ fileList as $ file ) { $ fullPath = Utils \ Util :: concatPath ( $ dirPath , $ file ) ; if ( is_dir ( $ fullPath ) ) { $ result &= $ this -> removeInDir ( $ fullPath , true ) ; } else if ( file_exists ( $ fullPath ) ) { $ result &= unlink ( $ fullPath ) ; } } } if ( $ removeWithDir && $ this -> isDirEmpty ( $ dirPath ) ) { $ result &= $ this -> rmdir ( $ dirPath ) ; } return ( bool ) $ result ; }
Remove all files inside given path

@param string $dirPath - directory path
@param bool $removeWithDir - if remove with directory

@return bool
Remove all files inside given path