diff options
| author | gingerBill <bill@gingerbill.org> | 2022-02-28 21:49:19 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-02-28 21:49:19 +0000 |
| commit | d4ccb69ccc56fb57cad48493a9e5e78ca3529a84 (patch) | |
| tree | c5395cc03aaaf5ea96156d729cdc5d2bc36d0e84 /src/parser.cpp | |
| parent | a70dde34dace7b0f579025332ea4e24b4a8b1354 (diff) | |
Check if directory exists with the same target executable name when building a directory
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 9659e8c18..f70afe346 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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)); 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; + } + } } |