scan_dir::rmdir_callback: rmdir the empty directory as default

This commit is contained in:
zsx 2019-02-02 14:18:17 +08:00
parent 0447653edd
commit 4934df5291
2 changed files with 18 additions and 6 deletions

View File

@ -23,15 +23,12 @@ public:
bool open(const char* path, bool recursive = true, bool rmdir_on = false);
/**
*
*
* rmdir
* @param path {const char*}
* @return {bool}
*/
virtual bool rmdir_callback(const char* path)
{
(void) path;
return false;
}
virtual bool rmdir_callback(const char* path);
/**
*

View File

@ -88,6 +88,21 @@ int scan_dir::rmdir_def(ACL_SCAN_DIR*, const char* path, void* ctx)
return me->rmdir_callback(path) ? 0 : -1;
}
bool scan_dir::rmdir_callback(const char* path)
{
#ifdef ACL_WINDOWS
if (_rmdir(path) == 0) {
return true;
#else
if (rmdir(path) == 0) {
return true;
#endif
} else {
logger_error("rmdir error=%s, path=%s", last_serror(), path);
return false;
}
}
const char* scan_dir::next_file(bool full /* = false */)
{
if (scan_ == NULL) {