@@ -108,7 +108,7 @@ bool Directory::refresh()
108108
109109 if (dir == NULL )
110110 {
111- DEBUG_MSG (" Failed to open directory %s" , path.c_str ());
111+ ERROR_MSG (" Failed to open directory %s (%s) " , path.c_str (), strerror (errno ));
112112
113113 return false ;
114114 }
@@ -168,6 +168,10 @@ bool Directory::refresh()
168168 DEBUG_MSG (" File not used %s" , name.c_str ());
169169 }
170170 }
171+ else
172+ {
173+ WARNING_MSG (" Failed to stat %s (%s)" , fullPath.c_str (), strerror (errno));
174+ }
171175 }
172176 }
173177
@@ -192,7 +196,7 @@ bool Directory::refresh()
192196 if (errno == ENOENT)
193197 goto finished;
194198
195- DEBUG_MSG (" Failed to open directory %s" , path.c_str ());
199+ ERROR_MSG (" Failed to open directory %s (%s) " , path.c_str (), strerror (errno ));
196200
197201 return false ;
198202 }
@@ -218,6 +222,8 @@ bool Directory::refresh()
218222
219223 valid = true ;
220224
225+ DEBUG_MSG (" Directory %s refreshed: %zu files, %zu subdirs" , path.c_str (), files.size (), subDirs.size ());
226+
221227 return true ;
222228}
223229
@@ -255,10 +261,16 @@ bool Directory::rmdir(std::string name, bool doRefresh /* = false */)
255261
256262#ifndef _WIN32
257263 if (::rmdir (fullPath.c_str ()) != 0 )
264+ {
265+ ERROR_MSG (" Failed to remove directory %s (%s)" , fullPath.c_str (), strerror (errno));
258266 return false ;
267+ }
259268#else
260269 if (_rmdir (fullPath.c_str ()) != 0 )
270+ {
271+ ERROR_MSG (" Failed to remove directory %s (%s)" , fullPath.c_str (), strerror (errno));
261272 return false ;
273+ }
262274#endif
263275 if (doRefresh)
264276 return refresh ();
@@ -271,9 +283,19 @@ bool Directory::remove(std::string name)
271283 std::string fullPath = path + OS_PATHSEP + name;
272284
273285#ifndef _WIN32
274- return (!::remove (fullPath.c_str ()) && refresh ());
286+ if (::remove (fullPath.c_str ()) != 0 )
287+ {
288+ ERROR_MSG (" Failed to remove file %s (%s)" , fullPath.c_str (), strerror (errno));
289+ return false ;
290+ }
291+ return refresh ();
275292#else
276- return (!_unlink (fullPath.c_str ()) && refresh ());
293+ if (_unlink (fullPath.c_str ()) != 0 )
294+ {
295+ ERROR_MSG (" Failed to remove file %s (%s)" , fullPath.c_str (), strerror (errno));
296+ return false ;
297+ }
298+ return refresh ();
277299#endif
278300}
279301
0 commit comments