diff --git a/mongoose.c b/mongoose.c
index 2fb165dab162155abf9f2d38ee3fe3758bbc360e..b245017c257cbdba73135c91a906f1f251160f72 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -2609,7 +2609,7 @@ static int remove_directory(const char *dir) {
 static void handle_delete(struct connection *conn, const char *path) {
   file_stat_t st;
 
-  if (!stat(path, &st)) {
+  if (stat(path, &st) != 0) {
     send_http_error(conn, 404, NULL);
   } else if (S_ISDIR(st.st_mode)) {
     remove_directory(path);