summaryrefslogtreecommitdiff
path: root/Meta/Lagom/Tools/ConfigureComponents
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2021-11-01 16:11:36 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-02 11:36:23 +0100
commit686efb6737d28640354cc2b1c07d414b5ae076e6 (patch)
tree94a813d71e775a837439d9196abdcd53ca4f0953 /Meta/Lagom/Tools/ConfigureComponents
parent9f6eabd73a76daa0da5521770a28e648523961a7 (diff)
downloadserenity-686efb6737d28640354cc2b1c07d414b5ae076e6.zip
ConfigureComponents: Reduce duplicated code
Diffstat (limited to 'Meta/Lagom/Tools/ConfigureComponents')
-rw-r--r--Meta/Lagom/Tools/ConfigureComponents/main.cpp18
1 files changed, 3 insertions, 15 deletions
diff --git a/Meta/Lagom/Tools/ConfigureComponents/main.cpp b/Meta/Lagom/Tools/ConfigureComponents/main.cpp
index 7f6949416d..ac80d7cc09 100644
--- a/Meta/Lagom/Tools/ConfigureComponents/main.cpp
+++ b/Meta/Lagom/Tools/ConfigureComponents/main.cpp
@@ -45,18 +45,6 @@ enum class WhiptailMode {
Checklist
};
-static Optional<String> get_current_working_directory()
-{
- char* cwd = getcwd(nullptr, 0);
- if (!cwd) {
- perror("getcwd");
- return {};
- }
- String data { cwd };
- free(cwd);
- return data;
-}
-
static Vector<ComponentData> read_component_data(Core::ConfigFile const& config_file)
{
VERIFY(!config_file.read_entry("Global", "build_everything", {}).is_empty());
@@ -236,10 +224,10 @@ int main()
return 1;
}
- auto current_working_directory = get_current_working_directory();
- if (!current_working_directory.has_value())
+ auto current_working_directory = Core::File::current_working_directory();
+ if (current_working_directory.is_null())
return 1;
- auto lexical_cwd = LexicalPath(*current_working_directory);
+ auto lexical_cwd = LexicalPath(current_working_directory);
auto& parts = lexical_cwd.parts_view();
if (parts.size() < 2 || parts[parts.size() - 2] != "Build") {
warnln("\e[31mError:\e[0m This program needs to be executed from inside 'Build/*'.");