New list dir api
This commit is contained in:
@@ -202,8 +202,9 @@ int Run(Strs s) {
|
||||
|
||||
Strs ListDir(char *dir) {
|
||||
Strs result = {};
|
||||
S8_List files = OS_ListDir(Perm, S8_MakeFromChar(dir), 0);
|
||||
S8_For(it, files) result.add(it->string);
|
||||
for (OS_FileIter it = OS_IterateFiles(Perm, S8_MakeFromChar(dir)); OS_IsValid(it); OS_Advance(&it)) {
|
||||
result.add(S8_Copy(Perm, it.absolute_path));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,9 @@ int main(int argument_count, char **arguments) {
|
||||
// Search for build file in the project directory
|
||||
S8_String build_file = {0};
|
||||
{
|
||||
S8_List files_current_dir = OS_ListDir(Perm, S8_Lit(".."), 0);
|
||||
for (S8_Node *it = files_current_dir.first; it; it = it->next) {
|
||||
if (S8_Find(it->string, S8_Lit("build_file.c"), S8_IgnoreCase)) {
|
||||
build_file = it->string;
|
||||
for (OS_FileIter it = OS_IterateFiles(Perm, S8_Lit("..")); OS_IsValid(it); OS_Advance(&it)) {
|
||||
if (S8_Find(it.filename, S8_Lit("build_file.c"), S8_IgnoreCase)) {
|
||||
build_file = it.absolute_path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,9 +38,8 @@ int main(int argument_count, char **arguments) {
|
||||
}
|
||||
}
|
||||
|
||||
S8_String a = S8_ChopLastPeriod(build_file);
|
||||
S8_String b = S8_SkipToLastSlash(a);
|
||||
S8_String exe_name = S8_Format(Perm, "%.*s.exe", S8_Expand(b));
|
||||
S8_String name_no_ext = S8_GetNameNoExt(build_file);
|
||||
S8_String exe_name = S8_Format(Perm, "%.*s.exe", S8_Expand(name_no_ext));
|
||||
|
||||
// Compile the build file only if code changed
|
||||
if (SRC_WasModified(build_file, exe_name)) {
|
||||
|
||||
@@ -62,7 +62,7 @@ SRC_CacheEntry *SRC_FindCache(SRC_Cache *cache, uint64_t filepath_hash) {
|
||||
SRC_CacheEntry *SRC_HashFile(S8_String file, char *parent_file) {
|
||||
char *resolved_file = CL_ResolveFilepath(Perm, &SRC_SearchPaths, file.str, parent_file, false);
|
||||
if (!resolved_file) {
|
||||
IO_Printf("Failed to resolve file: %s\n", file.str);
|
||||
IO_Printf("Failed to resolve file: %.*s\n", S8_Expand(file));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ SRC_CacheEntry *SRC_HashFile(S8_String file, char *parent_file) {
|
||||
S8_String file_it = S8_MakeFromChar(iter.filename);
|
||||
SRC_CacheEntry *cache = SRC_HashFile(file_it, resolved_file);
|
||||
if (!cache) {
|
||||
IO_Printf("Missing cache for: %s\n", file_it.str);
|
||||
IO_Printf("Missing cache for: %.*s\n", S8_Expand(file_it));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user