Subversion Repositories tpanel

Rev

Rev 101 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 101 Rev 119
Line 392... Line 392...
392
    }
392
    }
393
 
393
 
394
    return false;
394
    return false;
395
}
395
}
396
 
396
 
-
 
397
/**
-
 
398
 * @brief TDirectory::dropDir deletes all files in a directory
-
 
399
 * This methos deletes only the files in a given directory and leaves all
-
 
400
 * subdirectories along with the files in them alone.
-
 
401
 *
-
 
402
 * @param path  A valid path. The files in this path will be deleted.
-
 
403
 * @return On success TRUE is returned.
-
 
404
 */
-
 
405
bool TDirectory::dropDir(const string& path)
-
 
406
{
-
 
407
    DECL_TRACER("TDirectory::dropDir(const string& path)");
-
 
408
 
-
 
409
    if (path.empty())
-
 
410
        return 0;
-
 
411
 
-
 
412
    int count = 0;
-
 
413
 
-
 
414
    try
-
 
415
    {
-
 
416
        for(auto& p: fs::directory_iterator(path))
-
 
417
        {
-
 
418
            string f = fs::path(p.path()).filename();
-
 
419
 
-
 
420
            if (checkDot(f))
-
 
421
                continue;
-
 
422
#if __GNUC__ < 9
-
 
423
            if (fs::is_directory(p.path()))
-
 
424
#else
-
 
425
            if (p.is_directory())
-
 
426
#endif
-
 
427
                continue;
-
 
428
 
-
 
429
            fs::remove(p.path());
-
 
430
            count++;
-
 
431
        }
-
 
432
    }
-
 
433
    catch (std::exception& e)
-
 
434
    {
-
 
435
        MSG_ERROR("Error dir drop: " << e.what());
-
 
436
        return false;
-
 
437
    }
-
 
438
 
-
 
439
    MSG_DEBUG("Deleted " << count << " files.");
-
 
440
    return true;
-
 
441
}
-
 
442
 
-
 
443
bool TDirectory::dropFile(const string& fname)
-
 
444
{
-
 
445
    DECL_TRACER("TDirectory::dropFile(const string& fname)");
-
 
446
 
-
 
447
    try
-
 
448
    {
-
 
449
        fs::remove(fname);
-
 
450
    }
-
 
451
    catch (std::exception& e)
-
 
452
    {
-
 
453
        MSG_ERROR("Error removing file " << fname << "!");
-
 
454
        return false;
-
 
455
    }
-
 
456
 
-
 
457
    return true;
-
 
458
}
-
 
459
 
397
string TDirectory::getEntryWithEnd(const string &end)
460
string TDirectory::getEntryWithEnd(const string &end)
398
{
461
{
399
    DECL_TRACER("TDirectory::getEntryWithEnd(const string &end)");
462
    DECL_TRACER("TDirectory::getEntryWithEnd(const string &end)");
400
 
463
 
401
    if (entries.size() == 0)
464
    if (entries.size() == 0)