本文整理汇总了PHP中removeDir函数的典型用法代码示例。如果您正苦于以下问题:PHP removeDir函数的具体用法?PHP removeDir怎么用?PHP removeDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了removeDir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeDir
function removeDir($path)
{
// Add trailing slash to $path if one is not there
if (substr($path, -1, 1) != "/") {
$path .= "/";
}
$files = glob($path . "*");
if (count($files) > 0) {
foreach ($files as $file) {
if (is_file($file) === true) {
// Remove each file in this Directory
if (unlink($file) === false) {
return false;
}
} else {
if (is_dir($file) === true) {
// If this Directory contains a Subdirectory, run this Function on it
if (removeDir($file) == false) {
return false;
}
}
}
}
}
// Remove Directory once Files have been removed (If Exists)
if (is_dir($path) === true) {
if (rmdir($path) == false) {
return false;
}
}
return true;
}
示例2: test_clean
function test_clean()
{
logTestMessage(NEW_LINE_LOG . " >> Cleanup all test users...");
removeDir(USER_DIR);
// including files
logTestMessage("End cleanup");
}
示例3: removeDir
/**
* Recursively delete a directory
*
* @param string $path Intial path to delete
*/
function removeDir($path)
{
$normal_files = glob($path . "*");
$hidden_files = glob($path . "\\.?*");
$all_files = array_merge($normal_files, $hidden_files);
foreach ($all_files as $file) {
/* Skip pseudo links to current and parent dirs (./ and ../). */
if (preg_match("/(\\.|\\.\\.)\$/", $file)) {
continue;
}
if (is_file($file) === TRUE) {
/* Remove each file in this Directory */
unlink($file);
echo _gettext('Removed File') . ': ' . $file . "<br />";
} else {
if (is_dir($file) === TRUE) {
/* If this Directory contains a Subdirectory, run this Function on it */
removeDir($file);
}
}
}
/* Remove Directory once Files have been removed (If Exists) */
if (is_dir($path) === TRUE) {
rmdir($path);
echo '<br />' . _gettext('Removed Directory') . ': ' . $path . "<br /><br />";
}
}
示例4: removeDir
function removeDir($dir)
{
if (file_exists($dir)) {
// create directory pointer
$dp = opendir($dir) or die('ERROR: Cannot open directory');
// read directory contents
// delete files found
// call itself recursively if directories found
while ($file = readdir($dp)) {
if ($file != '.' && $file != '..') {
if (is_file("{$dir}/{$file}")) {
unlink("{$dir}/{$file}");
} else {
if (is_dir("{$dir}/{$file}")) {
removeDir("{$dir}/{$file}");
}
}
}
}
// close directory pointer
closedir($dp);
// remove now-empty directory
if (rmdir($dir)) {
return true;
} else {
return false;
}
}
}
示例5: checkIsEmpty
public function checkIsEmpty($ftp, $ftp_folder, $file)
{
$directory = explode('/', $file);
if (count($directory) > 1) {
unset($directory[count($directory) - 1]);
$path = implode('/', $directory);
removeDir($ftp_folder, $path, $ftp);
}
}
示例6: deleteAction
public function deleteAction()
{
if ($this->getConfig()->get('default_layout') == $this->getRequest()->getParam('key')) {
$this->addMessage('cantDeleteDefaultLayout');
} else {
removeDir(APPLICATION_PATH . '/layouts/' . $this->getRequest()->getParam('key'));
$this->addMessage('deleteSuccess');
}
$this->redirect(array('action' => 'index'));
}
示例7: removeDir
function removeDir($dir)
{
if (!file_exists($dir)) {
return false;
}
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file) {
is_dir("{$dir}/{$file}") && !is_link($dir) ? removeDir("{$dir}/{$file}") : unlink("{$dir}/{$file}");
}
return rmdir($dir);
}
示例8: removeDir
function removeDir($path)
{
foreach (glob($path . "/*") as $file) {
if (is_dir($file)) {
removeDir($file);
} else {
unlink($file);
}
}
rmdir($path);
}
示例9: removeDir
function removeDir($path)
{
// Normalise $path.
$path = rtrim($path, '/') . '/';
// Remove all child files and directories.
$items = glob($path . '*');
foreach ($items as $item) {
is_dir($item) ? removeDir($item) : unlink($item);
}
// Remove directory.
rmdir($path);
}
示例10: removeDir
function removeDir($path)
{
$dir = new DirectoryIterator($path);
foreach ($dir as $fileinfo) {
if ($fileinfo->isFile() || $fileinfo->isLink()) {
unlink($fileinfo->getPathName());
} elseif (!$fileinfo->isDot() && $fileinfo->isDir()) {
removeDir($fileinfo->getPathName());
}
}
rmdir($path);
}
示例11: deleteAction
public function deleteAction()
{
$modules = new \Modules\Admin\Mappers\Module();
$key = $this->getRequest()->getParam('key');
if ($this->getRequest()->isSecure()) {
$configClass = '\\Modules\\' . ucfirst($key) . '\\Config\\config';
$config = new $configClass($this->getTranslator());
$config->uninstall();
$modules->delete($key);
removeDir(APPLICATION_PATH . '/modules/' . $this->getRequest()->getParam('key'));
$this->addMessage('deleteSuccess');
}
$this->redirect(array('action' => 'index'));
}
示例12: my_delete
/**
* Delete a file or a directory
*
* @author - Hugues Peeters
* @param - $file (String) - the path of file or directory to delete
* @return - bolean - true if the delete succeed
* bolean - false otherwise.
* @see - delete() uses check_name_exist() and removeDir() functions
*/
function my_delete($file)
{
if (check_name_exist($file)) {
if (is_file($file)) {
unlink($file);
return true;
} elseif (is_dir($file)) {
removeDir($file);
return true;
}
} else {
return false;
// no file or directory to delete
}
}
示例13: cherry_restore_callback
function cherry_restore_callback()
{
$theme_folder = isset($_GET['theme_folder']) ? $_GET['theme_folder'] : '';
if (!$theme_folder) {
wp_die('File not provided', 'Error');
}
$file = str_replace('\\', '/', WP_CONTENT_DIR) . '/themes_backup/' . $theme_folder . ".zip";
$themes_folder = str_replace('\\', '/', get_theme_root()) . '/' . $theme_folder;
if (file_exists($file)) {
removeDir($themes_folder);
cherry_unzip_backup($file, $themes_folder);
} else {
echo theme_locals("unfortunately") . $theme_folder . theme_locals("please_try");
}
}
示例14: removeDir
function removeDir($dirName)
{
if (!is_dir($dirName)) {
return @unlink($dirName);
}
$handle = @opendir($dirName);
while (($file = @readdir($handle)) !== false) {
if ($file != '.' && $file != '..') {
$dir = $dirName . '/' . $file;
is_dir($dir) ? removeDir($dir) : @unlink($dir);
}
}
closedir($handle);
return true;
}
示例15: removeDir
function removeDir($dir)
{
if (is_dir($dir)) {
$files = scandir($dir);
foreach ($files as $file) {
if ($file != "." && $file != "..") {
removeDir("{$dir}/{$file}");
}
}
rmdir($dir);
} else {
if (file_exists($dir)) {
unlink($dir);
}
}
}