| 47 | } |
| 48 | |
| 49 | bool scan_dir::open(const char* path, bool recursive /* = true */, |
| 50 | bool rmdir_on /* = false */) |
| 51 | { |
| 52 | if (path == NULL || *path == 0) { |
| 53 | logger_error("path null"); |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | // �ȹر�֮ǰ���ܴľ�����Է�ֹ��Դй© |
| 58 | close(); |
| 59 | |
| 60 | unsigned flags = 0; |
| 61 | if (recursive) { |
| 62 | flags |= ACL_SCAN_FLAG_RECURSIVE; |
| 63 | } |
| 64 | if (rmdir_on) { |
| 65 | flags |= ACL_SCAN_FLAG_RMDIR; |
| 66 | } |
| 67 | |
| 68 | path_ = acl_mystrdup(path); |
| 69 | scan_ = acl_scan_dir_open2(path_, flags); |
| 70 | if (scan_ == NULL) { |
| 71 | logger_error("open dir: %s error: %s", path_, last_serror()); |
| 72 | acl_myfree(path_); |
| 73 | return false; |
| 74 | } |
| 75 | |
| 76 | if (rmdir_on) { |
| 77 | set_rmdir_callback(rmdir_def, this); |
| 78 | } |
| 79 | |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | void scan_dir::set_rmdir_callback(int (*fn)(ACL_SCAN_DIR*, const char*, void*), |
| 84 | void* ctx) |
no test coverage detected