*/
#include "filesys.h"
+#include "strfnd.h"
#include <iostream>
#include <string.h>
}
else
{
+ // NOTE:
+ // Be very sure to not include '..' in the results, it will
+ // result in an epic failure when deleting stuff.
+
DirListNode node;
node.name = FindFileData.cFileName;
node.dir = FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
- listing.push_back(node);
+ if(node.name != "." && node.name != "..")
+ listing.push_back(node);
// List all the other files in the directory.
while (FindNextFile(hFind, &FindFileData) != 0)
DirListNode node;
node.name = FindFileData.cFileName;
node.dir = FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
- listing.push_back(node);
+ if(node.name != "." && node.name != "..")
+ listing.push_back(node);
}
dwError = GetLastError();
{
std::cerr<<"Removing \""<<path<<"\""<<std::endl;
- return false;
+ //return false;
// This silly function needs a double-null terminated string...
// Well, we'll just make sure it has at least two, then.
}
while ((dirp = readdir(dp)) != NULL) {
+ // NOTE:
+ // Be very sure to not include '..' in the results, it will
+ // result in an epic failure when deleting stuff.
if(dirp->d_name[0]!='.'){
DirListNode node;
node.name = dirp->d_name;
if(dirp->d_type == DT_DIR) node.dir = true;
else node.dir = false;
- listing.push_back(node);
+ if(node.name != "." && node.name != "..")
+ listing.push_back(node);
}
}
closedir(dp);
std::vector<DirListNode> list = GetDirListing(path);
for(unsigned int i=0; i<list.size(); i++)
{
- std::string childpath = path+"/"+list[i].name;
+ if(trim(list[i].name) == "." || trim(list[i].name) == "..")
+ continue;
+ std::string childpath = path + "/" + list[i].name;
bool r = RecursiveDelete(childpath);
if(r == false)
{