#151656 - darkchild - Sun Mar 02, 2008 12:34 am
ok guys, I'm going for a recursive folder killer, this is what I've done so far:
yet all it does is go to that folder, delete all files in it, but not the subfolders.. not the subfolder's files.
now, the syntax of this function:
recursivedelete ("currentdir", "nameofthefolderwearedeleting");
what am I doing wrong? :X
Edit : I posted this on the wrong section, can a mod move it to the right one? :X
Code: |
void recursivedelete(const char *folder, const char *dir)
{ DIR_ITER* recur; bool temp; char *fullpath = " "; sprintf(fullpath, "%s%s/", dir, folder); recur = diropen (fullpath); if (recur != NULL) { while (dirnext(recur, filename, &st) == 0) { if ((strcmp(filename, ".") !=0) & (strcmp(filename, "..") !=0)) { temp = (st.st_mode & S_IFDIR ? true : false); if (temp == true) { sprintf(fullpath, "%s%s/", dir, folder); recursivedelete(filename, fullpath ); unlink(fullpath); } else { sprintf(fullpath, "%s%s/%s", dir, folder, filename); PA_OutputText(1,0,i +1, "%d : %s",i, fullpath); remove (fullpath ); } } } sprintf(fullpath, "%s%s/", dir, folder); unlink(fullpath); } } |
yet all it does is go to that folder, delete all files in it, but not the subfolders.. not the subfolder's files.
now, the syntax of this function:
recursivedelete ("currentdir", "nameofthefolderwearedeleting");
what am I doing wrong? :X
Edit : I posted this on the wrong section, can a mod move it to the right one? :X