output.cc (9398:6a348f61220c) output.cc (9550:e0e2c8f83d08)
1/*
2 * Copyright (c) 2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 219 unchanged lines hidden (view full) ---

228 files.erase(itr);
229 }
230
231 if (::remove(fname.c_str()) != 0)
232 fatal("Could not erase file '%s'\n", fname);
233 } else {
234 // assume 'name' is a directory
235 if (recursive) {
1/*
2 * Copyright (c) 2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 219 unchanged lines hidden (view full) ---

228 files.erase(itr);
229 }
230
231 if (::remove(fname.c_str()) != 0)
232 fatal("Could not erase file '%s'\n", fname);
233 } else {
234 // assume 'name' is a directory
235 if (recursive) {
236 DIR *dir = opendir(fname.c_str());
236 DIR *subdir = opendir(fname.c_str());
237
238 // silently ignore removal request for non-existent directory
237
238 // silently ignore removal request for non-existent directory
239 if ((!dir) && (errno == ENOENT))
239 if ((!subdir) && (errno == ENOENT))
240 return;
241
242 // fail on other errors
240 return;
241
242 // fail on other errors
243 if (!dir) {
243 if (!subdir) {
244 perror("opendir");
245 fatal("Error opening directory for recursive removal '%s'\n",
246 fname);
247 }
248
244 perror("opendir");
245 fatal("Error opening directory for recursive removal '%s'\n",
246 fname);
247 }
248
249 struct dirent *de = readdir(dir);
249 struct dirent *de = readdir(subdir);
250 while (de != NULL) {
251 // ignore files starting with a '.'; user must delete those
252 // manually if they really want to
253 if (de->d_name[0] != '.')
254 remove(name + PATH_SEPARATOR + de->d_name, recursive);
255
250 while (de != NULL) {
251 // ignore files starting with a '.'; user must delete those
252 // manually if they really want to
253 if (de->d_name[0] != '.')
254 remove(name + PATH_SEPARATOR + de->d_name, recursive);
255
256 de = readdir(dir);
256 de = readdir(subdir);
257 }
258 }
259
260 // try to force recognition that we deleted the files in the directory
261 sync();
262
263 if (::remove(fname.c_str()) != 0) {
264 perror("Warning! 'remove' failed. Could not erase directory.");
265 }
266 }
267}
257 }
258 }
259
260 // try to force recognition that we deleted the files in the directory
261 sync();
262
263 if (::remove(fname.c_str()) != 0) {
264 perror("Warning! 'remove' failed. Could not erase directory.");
265 }
266 }
267}