FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
cli_paths.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (c) 2025-present FERS Contributors (see AUTHORS.md).
3
4#include "cli_paths.h"
5
6namespace core
7{
8 std::filesystem::path resolveOutputDir(const std::string& script_file,
9 const std::optional<std::string>& output_dir) noexcept
10 {
11 if (output_dir)
12 {
13 return std::filesystem::path(*output_dir);
14 }
15
16 std::filesystem::path default_out_dir = std::filesystem::path(script_file).parent_path();
17 if (default_out_dir.empty())
18 {
19 default_out_dir = ".";
20 }
21
22 return default_out_dir;
23 }
24
25 std::filesystem::path resolveKmlOutputPath(const std::string& script_file,
26 const std::filesystem::path& final_output_dir,
27 const std::optional<std::string>& kml_file) noexcept
28 {
29 if (kml_file && !kml_file->empty())
30 {
31 const std::filesystem::path provided_kml_path(*kml_file);
32 if (provided_kml_path.has_parent_path() || provided_kml_path.is_absolute())
33 {
34 return provided_kml_path;
35 }
36
37 return final_output_dir / provided_kml_path;
38 }
39
40 std::filesystem::path kml_output_path = final_output_dir / std::filesystem::path(script_file).filename();
41 kml_output_path.replace_extension(".kml");
42 return kml_output_path;
43 }
44}
std::filesystem::path resolveKmlOutputPath(const std::string &script_file, const std::filesystem::path &final_output_dir, const std::optional< std::string > &kml_file) noexcept
Definition cli_paths.cpp:25
std::filesystem::path resolveOutputDir(const std::string &script_file, const std::optional< std::string > &output_dir) noexcept
Definition cli_paths.cpp:8