Changeset 681
- Timestamp:
- Aug 2, 2008, 10:13:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/rmdirhier.cc
r680 r681 64 64 void rmdirhier__(const std::string& dir) 65 65 { 66 struct stat buf;67 // using lstat because links should not be treated as dirs68 lstat(dir.c_str(),&buf);69 // check if dir - if not delete the node70 if (!(buf.st_mode & S_IFDIR)) {71 // Make sure file is removable before removing it72 chmod(dir.c_str(),S_IWRITE);73 if (unlink(dir.c_str()))74 throw FileDeleteError(dir);75 return;76 }77 66 if (chdir(dir.c_str())) 78 67 throw BadDirectory(dir); … … 84 73 throw DirectoryOpenError(dir); 85 74 while ((entry=readdir(dp)) != NULL) { 75 struct stat buf; 86 76 if ((std::string(entry->d_name) == ".") || 87 77 (std::string(entry->d_name) == "..")) 88 78 continue; 89 rmdirhier__(entry->d_name); 79 stat(entry->d_name,&buf); 80 if (buf.st_mode & S_IFDIR) 81 rmdirhier__(entry->d_name); // sub-directory 82 else { 83 // Make sure file is removable before removing it 84 chmod(entry->d_name,S_IWRITE); 85 if (unlink(entry->d_name)) 86 throw FileDeleteError(entry->d_name); 87 } 90 88 } 91 89 closedir(dp);
Note: See TracChangeset
for help on using the changeset viewer.