transcript browser wasm working
This commit is contained in:
@@ -13,15 +13,15 @@ struct mt_files_t {
|
||||
};
|
||||
|
||||
fn s8_t mt_resolve_path(ma_arena_t *arena, sb8_t *include_paths, s8_t filename, s8_t parent_file, b32 is_system_include) {
|
||||
if (OS_IsAbsolute(filename) && os_file_exists(filename)) {
|
||||
if (os_is_abs(filename) && os_exists(filename)) {
|
||||
return filename;
|
||||
}
|
||||
|
||||
// 1) (QUOTED_FORM) In the same directory as the file that contains the #include statement.
|
||||
if (!is_system_include && parent_file.len) {
|
||||
s8_t path = s8_printf(arena, "%S/%S", s8_chop_last_slash(parent_file), filename);
|
||||
if (os_file_exists(path)) {
|
||||
return OS_GetAbsolutePath(&Perm, path);
|
||||
if (os_exists(path)) {
|
||||
return os_abs(arena, path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ fn s8_t mt_resolve_path(ma_arena_t *arena, sb8_t *include_paths, s8_t filename,
|
||||
// 3) (BOTH FORMS) Along the path that's specified by each /I (or INCLUDE enviroment variable) compiler option.
|
||||
for (sb8_node_t *it = include_paths->first; it; it = it->next) {
|
||||
s8_t path = s8_printf(arena, "%S/%S", it->string, filename);
|
||||
if (os_file_exists(path)) {
|
||||
return OS_GetAbsolutePath(&Perm, path);
|
||||
if (os_exists(path)) {
|
||||
return os_abs(arena, path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ fn mt_file_t *mt_find_file(mt_files_t *root, s8_t name) {
|
||||
}
|
||||
|
||||
fn void mt__lex_files(ma_arena_t *arena, mt_files_t *root, s8_t path, sb8_t *include_paths) {
|
||||
s8_t content = OS_ReadFile(&Perm, path);
|
||||
s8_t content = os_read(arena, path);
|
||||
if (content.len == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -82,17 +82,17 @@ fn void mt__lex_files(ma_arena_t *arena, mt_files_t *root, s8_t path, sb8_t *inc
|
||||
|
||||
fn mt_files_t mt_lex_files(ma_arena_t *arena, s8_t path, sb8_t *include_paths) {
|
||||
mt_files_t files = {0};
|
||||
path = OS_GetAbsolutePath(&Perm, path);
|
||||
path = os_abs(arena, path);
|
||||
mt__lex_files(arena, &files, path, include_paths);
|
||||
return files;
|
||||
}
|
||||
|
||||
fn void mt_list_files_recursive(sb8_t *sb, s8_t path) {
|
||||
for (OS_FileIter iter = OS_IterateFiles(&Perm, path); OS_IsValid(iter); OS_Advance(&iter)) {
|
||||
if (iter.is_directory) {
|
||||
mt_list_files_recursive(sb, iter.absolute_path);
|
||||
for (os_iter_t *iter = os_iter(sb->arena, path); iter->is_valid; os_advance(iter)) {
|
||||
if (iter->is_directory) {
|
||||
mt_list_files_recursive(sb, iter->abs);
|
||||
} else {
|
||||
sb8_append(sb, iter.absolute_path);
|
||||
sb8_append(sb, iter->abs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,6 +134,6 @@ fn s8_t mt__main_path(ma_arena_t *arena, s8_t file) {
|
||||
fn sb8_t *mt_get_include_paths(ma_arena_t *arena) {
|
||||
sb8_t *result = ma_push_type(arena, sb8_t);
|
||||
result->arena = arena;
|
||||
sb8_append(result, OS_GetAbsolutePath(&Perm, s8("../src")));
|
||||
sb8_append(result, os_abs(arena, s8("../src")));
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user