65 | | while ( ( de = readdir ( dir ) ) != 0 ) { |
66 | | if ( strcmp ( de->d_name, "." ) && strcmp ( de->d_name, ".." ) ) { |
67 | | std::string subpath ( top ); |
68 | | subpath += de->d_name; |
69 | | remove_all ( subpath.c_str() ); |
70 | | } |
71 | | } |
72 | | } catch ( ... ) { |
73 | | closedir ( dir ); |
74 | | throw; |
75 | | } |
| 65 | while ( ( de = readdir ( dir ) ) != 0 ) { |
| 66 | if ( strcmp ( de->d_name, "." ) && strcmp ( de->d_name, ".." ) ) { |
| 67 | std::string subpath ( top ); |
| 68 | subpath += de->d_name; |
| 69 | remove_all ( subpath.c_str() ); |
| 70 | } |
| 71 | } |
| 72 | } catch ( ... ) { |
| 73 | closedir ( dir ); |
| 74 | throw; |
| 75 | } |
79 | | if ( rmdir ( path ) ) { |
80 | | std::string msg = "can't remove dir "; |
81 | | msg += path; |
82 | | bdm_error ( msg ); |
83 | | } |
84 | | } else { |
85 | | if ( ( errno == ENOTDIR ) || // Linux |
86 | | ( errno == EINVAL ) ) { // Windows |
87 | | if ( unlink ( path ) ) { |
88 | | std::string msg = "can't remove file "; |
89 | | msg += path; |
90 | | bdm_error ( msg ); |
91 | | } |
92 | | } else { |
93 | | if ( errno != ENOENT ) { |
94 | | std::string msg = "can't remove "; |
95 | | msg += path; |
96 | | bdm_error ( msg ); |
97 | | } else { |
98 | | // it wasn't there in the first place |
99 | | rv = false; |
100 | | } |
101 | | } |
102 | | } |
| 79 | if ( rmdir ( path ) ) { |
| 80 | std::string msg = "can't remove dir "; |
| 81 | msg += path; |
| 82 | bdm_error ( msg ); |
| 83 | } |
| 84 | } else { |
| 85 | if ( ( errno == ENOTDIR ) || // Linux |
| 86 | ( errno == EINVAL ) ) { // Windows |
| 87 | if ( unlink ( path ) ) { |
| 88 | std::string msg = "can't remove file "; |
| 89 | msg += path; |
| 90 | bdm_error ( msg ); |
| 91 | } |
| 92 | } else { |
| 93 | if ( errno != ENOENT ) { |
| 94 | std::string msg = "can't remove "; |
| 95 | msg += path; |
| 96 | bdm_error ( msg ); |
| 97 | } else { |
| 98 | // it wasn't there in the first place |
| 99 | rv = false; |
| 100 | } |
| 101 | } |
| 102 | } |