diff --git a/xml_converter/src/xml_converter.cpp b/xml_converter/src/xml_converter.cpp index 5d0c9238..fb0ebe78 100644 --- a/xml_converter/src/xml_converter.cpp +++ b/xml_converter/src/xml_converter.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -89,17 +90,32 @@ void move_supplementary_files(string input_directory, string output_directory) { } } -void read_taco_directory(string directory, map* marker_categories, vector* parsed_pois) { - vector xml_files = get_files_by_suffix(directory, ".xml"); - for (const string& path : xml_files) { - parse_xml_file(path, marker_categories, parsed_pois); +void read_taco_directory(string input_path, map* marker_categories, vector* parsed_pois) { + if (!filesystem::exists(input_path)) { + cout << "Error: " << input_path << " is not an existing directory or file" << endl; + } + else if (filesystem::is_directory(input_path)) { + vector xml_files = get_files_by_suffix(input_path, ".xml"); + for (const string& path : xml_files) { + parse_xml_file(path, marker_categories, parsed_pois); + } + } + else if (filesystem::is_regular_file(input_path)) { + parse_xml_file(input_path, marker_categories, parsed_pois); } } -void write_taco_directory(string directory, map* marker_categories, vector* parsed_pois) { +void write_taco_directory(string output_path, map* marker_categories, vector* parsed_pois) { // TODO: Exportion of XML Marker Packs File Structure #111 - string xml_filepath = directory + "/xml_file.xml"; - write_xml_file(xml_filepath, marker_categories, parsed_pois); + if (!has_suffix(output_path, "/")) { + output_path += "/"; + } + if (!filesystem::is_directory(output_path)) { + if (!filesystem::create_directory(output_path)) { + cout << "Error: " << output_path << "is not a valid directory path" << endl; + } + } + write_xml_file(output_path + "xml_file.xml", marker_categories, parsed_pois); } ////////////////////////////////////////////////////////////////////////////////