homebrewfilter/source/Tools/erase.cpp

25 lines
592 B
C++
Raw Normal View History

2011-09-25 19:47:02 +02:00
#include <stdio.h>
#include <string.h>
#include <dirent.h>
void DeleteDir(const char* dirname){
DIR *hdir;
struct dirent *entry;
hdir = opendir(dirname);
do
{
entry = readdir(hdir);
if (entry && strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0)
{
char erase[500];
sprintf(erase, "%s/%s", dirname, entry->d_name);
if(remove(erase) == -1)
DeleteDir(erase);
remove(erase);
}
} while (entry);
closedir(hdir);
remove(dirname);
}