Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows files and directories to inputs and handles them based on type #183

Merged
merged 10 commits into from
Nov 5, 2023
34 changes: 28 additions & 6 deletions xml_converter/src/xml_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <algorithm>
#include <chrono>
#include <cstddef>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <iterator>
Expand Down Expand Up @@ -89,16 +90,37 @@ void move_supplementary_files(string input_directory, string output_directory) {
}
}

void read_taco_directory(string directory, map<string, Category>* marker_categories, vector<Parseable*>* parsed_pois) {
vector<string> 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<string, Category>* marker_categories, vector<Parseable*>* 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<string> 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<string, Category>* marker_categories, vector<Parseable*>* parsed_pois) {
void write_taco_directory(string output_path, map<string, Category>* marker_categories, vector<Parseable*>* parsed_pois) {
// TODO: Exportion of XML Marker Packs File Structure #111
string xml_filepath = directory + "/xml_file.xml";
string xml_filepath;
if (!has_suffix(output_path, "/")) {
output_path += "/";
xml_filepath = output_path + "xml_file.xml";
}
else {
xml_filepath = output_path;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont understand why this does not have xml_file.xml

}

if (!filesystem::is_directory(output_path)) {
if (!filesystem::create_directory(output_path)) {
cout << "Error: " << output_path << "is not a valid directory path" << endl;
}
}
AsherGlick marked this conversation as resolved.
Show resolved Hide resolved
write_xml_file(xml_filepath, marker_categories, parsed_pois);
}

Expand Down