Browse Source

Err on empty directory packages

gingerBill 7 years ago
parent
commit
a5763d6fee
2 changed files with 8 additions and 5 deletions
  1. 4 1
      src/common.cpp
  2. 4 4
      src/parser.cpp

+ 4 - 1
src/common.cpp

@@ -751,7 +751,7 @@ enum ReadDirectoryError {
 	ReadDirectory_NotExists,
 	ReadDirectory_Permission,
 	ReadDirectory_NotDir,
-	ReadDirectory_EOF,
+	ReadDirectory_Empty,
 	ReadDirectory_Unknown,
 
 	ReadDirectory_COUNT,
@@ -858,6 +858,9 @@ ReadDirectoryError read_directory(String path, Array<FileInfo> *fi) {
 
 	} while (FindNextFileW(find_file, &file_data));
 
+	if (fi->count == 0) {
+		return ReadDirectory_Empty;
+	}
 
 	return ReadDirectory_None;
 }

+ 4 - 4
src/parser.cpp

@@ -4253,7 +4253,7 @@ ParseFileError parse_import(Parser *p, ImportedPackage imported_package) {
 		GB_ASSERT(import_path != list[0].fullpath);
 	}
 
-	if (rd_err != ReadDirectory_EOF && rd_err != ReadDirectory_None) {
+	if (rd_err != ReadDirectory_None) {
 		if (pos.line != 0) {
 			gb_printf_err("%.*s(%td:%td) ", LIT(pos.file), pos.line, pos.column);
 		}
@@ -4282,9 +4282,9 @@ ParseFileError parse_import(Parser *p, ImportedPackage imported_package) {
 			gb_printf_err("Unknown error whilst reading path %.*s\n", LIT(import_rel_path));
 			return ParseFile_InvalidFile;
 
-		case ReadDirectory_EOF:
-			gb_printf_err("Unknown error whilst reading path %.*s\n", LIT(import_rel_path));
-			return ParseFile_InvalidFile;
+		case ReadDirectory_Empty:
+			gb_printf_err("Empty directory: %.*s\n", LIT(import_rel_path));
+			return ParseFile_EmptyFile;
 		}
 	}