diff --git a/mythtv/programs/mythbackend/mainserver.cpp b/mythtv/programs/mythbackend/mainserver.cpp
index 8813652..436c711 100644
a
|
b
|
void MainServer::DoDeleteInDB(DeleteStruct *ds) |
2235 | 2235 | } |
2236 | 2236 | } |
2237 | 2237 | |
| 2238 | |
| 2239 | bool MainServer::removeDir(const QString &dirname) |
| 2240 | { |
| 2241 | QDir dir(dirname); |
| 2242 | |
| 2243 | if (!dir.exists()) |
| 2244 | return false; |
| 2245 | |
| 2246 | dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); |
| 2247 | QFileInfoList list = dir.entryInfoList(); |
| 2248 | QFileInfoList::const_iterator it = list.begin(); |
| 2249 | const QFileInfo *fi; |
| 2250 | |
| 2251 | while (it != list.end()) |
| 2252 | { |
| 2253 | fi = &(*it++); |
| 2254 | if (fi->isFile() && !fi->isSymLink()) |
| 2255 | { |
| 2256 | QFile::remove(fi->absoluteFilePath()); |
| 2257 | } |
| 2258 | else if (fi->isDir() && !fi->isSymLink()) |
| 2259 | { |
| 2260 | if(!removeDir(fi->absoluteFilePath())) return false; |
| 2261 | } |
| 2262 | } |
| 2263 | |
| 2264 | dir.rmdir(dirname); |
| 2265 | return true; |
| 2266 | } |
| 2267 | |
2238 | 2268 | /** |
2239 | 2269 | * \brief Deletes links and unlinks the main file and returns the descriptor. |
2240 | 2270 | * |
… |
… |
int MainServer::DeleteFile(const QString &filename, bool followLinks, |
2285 | 2315 | return -2; // valid result, not an error condition |
2286 | 2316 | } |
2287 | 2317 | |
2288 | | if (fd < 0) |
| 2318 | if (fd < 0 && errno != EISDIR) |
2289 | 2319 | LOG(VB_GENERAL, LOG_ERR, errmsg + ENO); |
2290 | 2320 | |
2291 | 2321 | return fd; |
2292 | 2322 | } |
2293 | 2323 | |
| 2324 | |
| 2325 | |
2294 | 2326 | /** \fn MainServer::OpenAndUnlink(const QString&) |
2295 | 2327 | * \brief Opens a file, unlinks it and returns the file descriptor. |
2296 | 2328 | * |
… |
… |
int MainServer::OpenAndUnlink(const QString &filename) |
2308 | 2340 | |
2309 | 2341 | if (fd == -1) |
2310 | 2342 | { |
2311 | | LOG(VB_GENERAL, LOG_ERR, msg + " could not open " + ENO); |
2312 | | return -1; |
2313 | | } |
2314 | | |
2315 | | if (unlink(fname.constData())) |
| 2343 | if (errno == EISDIR) |
| 2344 | { |
| 2345 | if(!removeDir(filename)) |
| 2346 | { |
| 2347 | LOG(VB_GENERAL, LOG_ERR, msg + " could not delete directory " + ENO); |
| 2348 | return -1; |
| 2349 | } |
| 2350 | } |
| 2351 | else |
| 2352 | { |
| 2353 | LOG(VB_GENERAL, LOG_ERR, msg + " could not open " + ENO); |
| 2354 | return -1; |
| 2355 | } |
| 2356 | } |
| 2357 | else if (unlink(fname.constData())) |
2316 | 2358 | { |
2317 | 2359 | LOG(VB_GENERAL, LOG_ERR, msg + " could not unlink " + ENO); |
2318 | 2360 | close(fd); |
diff --git a/mythtv/programs/mythbackend/mainserver.h b/mythtv/programs/mythbackend/mainserver.h
index 32084f9..9b5bf23 100644
a
|
b
|
class MainServer : public QObject, public MythSocketCBs |
256 | 256 | |
257 | 257 | void SetExitCode(int exitCode, bool closeApplication); |
258 | 258 | |
| 259 | static bool removeDir(const QString &dirname); |
259 | 260 | static int DeleteFile(const QString &filename, bool followLinks, |
260 | 261 | bool deleteBrokenSymlinks = false); |
261 | 262 | static int OpenAndUnlink(const QString &filename); |