From b45879a0f2a87ee51a425a89b30a88ee4c30b259 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 28 Apr 2021 00:14:40 -0500 Subject: [PATCH] Bugfix: Fake should ceate parent directories for the "path_headers". This really should be done for all cases like this, but for now just fix "path_headers" and add a todo comment. --- level_3/fake/c/private-build.c | 48 +++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 8985f20..62002f6 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -444,7 +444,33 @@ extern "C" { return; } - *status = f_directory_create(directorys[i]->string, mode); + // @todo implement this in a common function and use across project for creating parent directories. + for (f_array_length_t j = 0; j < directorys[i]->used; ++j) { + + if (directorys[i]->string[j] != f_path_separator_s[0]) continue; + + directorys[i]->string[j] = 0; + + *status = f_directory_exists(directorys[i]->string); + + if (F_status_is_error(*status) || *status == F_false) { + directorys[i]->string[j] = f_path_separator_s[0]; + + break; + } + + if (*status == F_file_found_not) { + *status = f_directory_create(directorys[i]->string, mode); + } + + directorys[i]->string[j] = f_path_separator_s[0]; + + if (F_status_is_error(*status)) break; + } // for + + if (F_status_is_fine(*status)) { + *status = f_directory_create(directorys[i]->string, mode); + } if (F_status_is_error(*status)) { if (F_status_set_fine(*status) == F_file_found) { @@ -2587,25 +2613,17 @@ extern "C" { char directory_headers[directory_headers_length + 1]; + memcpy(directory_headers, data->path_build_includes.string, data->path_build_includes.used); + if (data_build.setting.path_headers.used) { - memcpy(directory_headers, data->path_build_includes.string, data->path_build_includes.used); memcpy(directory_headers + data->path_build_includes.used, data_build.setting.path_headers.string, data_build.setting.path_headers.used); - - directory_headers[directory_headers_length] = 0; - - path_headers.string = directory_headers; - path_headers.used = directory_headers_length; - path_headers.size = directory_headers_length + 1; } - else { - memcpy(directory_headers, data->path_build_includes.string, data->path_build_includes.used); - directory_headers[directory_headers_length] = 0; + directory_headers[directory_headers_length] = 0; - path_headers.string = directory_headers; - path_headers.used = directory_headers_length; - path_headers.size = directory_headers_length + 1; - } + path_headers.string = directory_headers; + path_headers.used = directory_headers_length; + path_headers.size = directory_headers_length + 1; fake_build_copy(*data, mode, "header files", *path_sources, path_headers, data_build.setting.build_sources_headers, stage.file_sources_headers, data_build.setting.path_headers_preserve ? path_sources_base_length : 0, &status); } -- 1.8.3.1