mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Check if directory exists with the same target executable name when building a directory
This commit is contained in:
@@ -5719,6 +5719,22 @@ ParseFileError parse_packages(Parser *p, String init_filename) {
|
|||||||
error_line("Expected either a directory or a .odin file, got '%.*s'\n", LIT(init_filename));
|
error_line("Expected either a directory or a .odin file, got '%.*s'\n", LIT(init_filename));
|
||||||
return ParseFile_WrongExtension;
|
return ParseFile_WrongExtension;
|
||||||
}
|
}
|
||||||
|
} else if (init_fullpath.len != 0) {
|
||||||
|
String path = init_fullpath;
|
||||||
|
if (path[path.len-1] == '/') {
|
||||||
|
path.len -= 1;
|
||||||
|
}
|
||||||
|
if ((build_context.command_kind & Command__does_build) &&
|
||||||
|
build_context.build_mode == BuildMode_Executable) {
|
||||||
|
String short_path = filename_from_path(path);
|
||||||
|
char *cpath = alloc_cstring(heap_allocator(), short_path);
|
||||||
|
defer (gb_free(heap_allocator(), cpath));
|
||||||
|
|
||||||
|
if (gb_file_exists(cpath)) {
|
||||||
|
error_line("Please specify the executable name with -out:<string> as a directory exists with the same name in the current working directory");
|
||||||
|
return ParseFile_DirectoryAlreadyExists;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ enum ParseFileError {
|
|||||||
ParseFile_InvalidToken,
|
ParseFile_InvalidToken,
|
||||||
ParseFile_GeneralError,
|
ParseFile_GeneralError,
|
||||||
ParseFile_FileTooLarge,
|
ParseFile_FileTooLarge,
|
||||||
|
ParseFile_DirectoryAlreadyExists,
|
||||||
|
|
||||||
ParseFile_Count,
|
ParseFile_Count,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user