1
0
mirror of https://github.com/lammertb/libhttp.git synced 2025-12-22 04:02:04 +03:00

Error handling in remove_directory

This commit is contained in:
bel2125
2015-08-18 20:31:01 +02:00
parent c5d806bf44
commit 49b19deaad

View File

@@ -5287,6 +5287,7 @@ static int remove_directory(struct mg_connection *conn, const char *dir)
DIR *dirp; DIR *dirp;
struct de de; struct de de;
int truncated; int truncated;
int ok = 1;
if ((dirp = opendir(dir)) == NULL) { if ((dirp = opendir(dir)) == NULL) {
return 0; return 0;
@@ -5325,9 +5326,13 @@ static int remove_directory(struct mg_connection *conn, const char *dir)
if (de.file.membuf == NULL) { if (de.file.membuf == NULL) {
/* file is not in memory */ /* file is not in memory */
if (de.file.is_directory) { if (de.file.is_directory) {
remove_directory(conn, path); if (remove_directory(conn, path) == 0) {
ok = 0;
}
} else { } else {
mg_remove(path); if (mg_remove(path) == 0) {
ok = 0;
}
} }
} }
} }
@@ -5336,7 +5341,7 @@ static int remove_directory(struct mg_connection *conn, const char *dir)
IGNORE_UNUSED_RESULT(rmdir(dir)); IGNORE_UNUSED_RESULT(rmdir(dir));
} }
return 1; return ok;
} }
#endif #endif