diff --git a/xml_converter/integration_tests/test_cases/texture/input/pack/somedir/texture_three.png b/xml_converter/integration_tests/test_cases/texture/input/pack/somedir/texture_three.png
new file mode 100644
index 00000000..3faad497
Binary files /dev/null and b/xml_converter/integration_tests/test_cases/texture/input/pack/somedir/texture_three.png differ
diff --git a/xml_converter/integration_tests/test_cases/texture/input/pack/texture_one.png b/xml_converter/integration_tests/test_cases/texture/input/pack/texture_one.png
new file mode 100644
index 00000000..392885bb
Binary files /dev/null and b/xml_converter/integration_tests/test_cases/texture/input/pack/texture_one.png differ
diff --git a/xml_converter/integration_tests/test_cases/texture/input/pack/texture_two.png b/xml_converter/integration_tests/test_cases/texture/input/pack/texture_two.png
new file mode 100644
index 00000000..ce71402d
Binary files /dev/null and b/xml_converter/integration_tests/test_cases/texture/input/pack/texture_two.png differ
diff --git a/xml_converter/integration_tests/test_cases/texture/input/pack/xml_file.xml b/xml_converter/integration_tests/test_cases/texture/input/pack/xml_file.xml
index 490a4897..d7135b25 100644
--- a/xml_converter/integration_tests/test_cases/texture/input/pack/xml_file.xml
+++ b/xml_converter/integration_tests/test_cases/texture/input/pack/xml_file.xml
@@ -3,9 +3,9 @@
-
-
-
-
+
+
+
+
diff --git a/xml_converter/integration_tests/test_cases/texture/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/texture/output_proto/markers.bin
index 075d2117..93077c5e 100644
Binary files a/xml_converter/integration_tests/test_cases/texture/output_proto/markers.bin and b/xml_converter/integration_tests/test_cases/texture/output_proto/markers.bin differ
diff --git a/xml_converter/integration_tests/test_cases/texture/output_proto/somedir/texture_three.png b/xml_converter/integration_tests/test_cases/texture/output_proto/somedir/texture_three.png
new file mode 100644
index 00000000..3faad497
Binary files /dev/null and b/xml_converter/integration_tests/test_cases/texture/output_proto/somedir/texture_three.png differ
diff --git a/xml_converter/integration_tests/test_cases/texture/output_proto/texture_one.png b/xml_converter/integration_tests/test_cases/texture/output_proto/texture_one.png
new file mode 100644
index 00000000..392885bb
Binary files /dev/null and b/xml_converter/integration_tests/test_cases/texture/output_proto/texture_one.png differ
diff --git a/xml_converter/integration_tests/test_cases/texture/output_proto/texture_two.png b/xml_converter/integration_tests/test_cases/texture/output_proto/texture_two.png
new file mode 100644
index 00000000..ce71402d
Binary files /dev/null and b/xml_converter/integration_tests/test_cases/texture/output_proto/texture_two.png differ
diff --git a/xml_converter/integration_tests/test_cases/texture/output_xml/somedir/texture_three.png b/xml_converter/integration_tests/test_cases/texture/output_xml/somedir/texture_three.png
new file mode 100644
index 00000000..3faad497
Binary files /dev/null and b/xml_converter/integration_tests/test_cases/texture/output_xml/somedir/texture_three.png differ
diff --git a/xml_converter/integration_tests/test_cases/texture/output_xml/texture_one.png b/xml_converter/integration_tests/test_cases/texture/output_xml/texture_one.png
new file mode 100644
index 00000000..392885bb
Binary files /dev/null and b/xml_converter/integration_tests/test_cases/texture/output_xml/texture_one.png differ
diff --git a/xml_converter/integration_tests/test_cases/texture/output_xml/texture_two.png b/xml_converter/integration_tests/test_cases/texture/output_xml/texture_two.png
new file mode 100644
index 00000000..ce71402d
Binary files /dev/null and b/xml_converter/integration_tests/test_cases/texture/output_xml/texture_two.png differ
diff --git a/xml_converter/integration_tests/test_cases/texture/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/texture/output_xml/xml_file.xml
index 5af46f44..5fa93e32 100644
--- a/xml_converter/integration_tests/test_cases/texture/output_xml/xml_file.xml
+++ b/xml_converter/integration_tests/test_cases/texture/output_xml/xml_file.xml
@@ -3,9 +3,9 @@
-
-
-
-
+
+
+
+
diff --git a/xml_converter/src/attribute/image.cpp b/xml_converter/src/attribute/image.cpp
index dcbe677d..ad8cdf04 100644
--- a/xml_converter/src/attribute/image.cpp
+++ b/xml_converter/src/attribute/image.cpp
@@ -1,12 +1,12 @@
#include "image.hpp"
-#include
+#include
#include
#include
#include "../rapid_helpers.hpp"
#include "../rapidxml-1.13/rapidxml.hpp"
-#include "waypoint.pb.h"
+#include "../string_helper.hpp"
using namespace std;
@@ -21,8 +21,10 @@ void xml_attribute_to_image(
XMLReaderState* state,
Image* value,
bool* is_set) {
- value->filename = get_attribute_value(input);
- value->original_filepath = state->xml_filedir + "/" + value->filename;
+ Image image;
+ image.filename = get_attribute_value(input);
+ image.original_filepath = join_file_paths(state->marker_pack_root_directory, image.filename);
+ *value = image;
*is_set = true;
}
@@ -33,8 +35,16 @@ void xml_attribute_to_image(
////////////////////////////////////////////////////////////////////////////////
string image_to_xml_attribute(
const string& attribute_name,
- XMLWriterState*,
+ XMLWriterState* state,
const Image* value) {
+ if (filesystem::exists(filesystem::path(value->original_filepath))) {
+ filesystem::path output_path = filesystem::path(state->marker_pack_root_directory) / value->filename;
+ filesystem::create_directories(output_path.parent_path());
+ filesystem::copy_file(filesystem::path(value->original_filepath), output_path, filesystem::copy_options::overwrite_existing);
+ }
+ else {
+ cout << "Warning: File path " << value->original_filepath << " not found." << endl;
+ }
return " " + attribute_name + "=\"" + value->filename + "\"";
}
@@ -48,9 +58,9 @@ void proto_to_image(
ProtoReaderState* state,
Image* value,
bool* is_set) {
- // TODO: this is broken until we load the string index into the proto read state
Image image;
- // image.path = input.path();
+ image.filename = state->textures[input].filepath();
+ image.original_filepath = join_file_paths(state->marker_pack_root_directory, image.filename);
*value = image;
*is_set = true;
}
@@ -75,6 +85,14 @@ void image_to_proto(
texture_index = state->textures.size();
state->texture_path_to_textures_index[value.original_filepath] = texture_index;
state->textures.push_back(&value);
+ if (filesystem::exists(filesystem::path(value.original_filepath))) {
+ filesystem::path output_path = filesystem::path(state->marker_pack_root_directory) / value.filename;
+ filesystem::create_directories(output_path.parent_path());
+ filesystem::copy_file(filesystem::path(value.original_filepath), output_path, filesystem::copy_options::overwrite_existing);
+ }
+ else {
+ cout << "Warning: File path " << value.original_filepath << " not found." << endl;
+ }
}
setter(texture_index);
diff --git a/xml_converter/src/attribute/trail_data.cpp b/xml_converter/src/attribute/trail_data.cpp
index c6fd8c26..341de3c3 100644
--- a/xml_converter/src/attribute/trail_data.cpp
+++ b/xml_converter/src/attribute/trail_data.cpp
@@ -32,7 +32,7 @@ void xml_attribute_to_trail_data(
bool* is_map_id_set) {
TrailData trail_data;
string trail_data_relative_path = get_attribute_value(input);
- if (state->xml_filedir == "") {
+ if (state->marker_pack_root_directory == "") {
throw "Error: Marker pack base directory is an empty string";
}
if (trail_data_relative_path == "") {
@@ -41,7 +41,7 @@ void xml_attribute_to_trail_data(
}
ifstream trail_data_file;
- string trail_path = state->xml_filedir + "/" + trail_data_relative_path;
+ string trail_path = join_file_paths(state->marker_pack_root_directory, trail_data_relative_path);
trail_data_file.open(trail_path, ios::in | ios::binary);
if (!trail_data_file.good()) {
errors->push_back(new XMLAttributeValueError("No trail file found at " + trail_path, input));
@@ -132,7 +132,7 @@ string trail_data_to_xml_attribute(
}
string trail_file_name = long_to_hex_string(djb2_hash(byte_array, byte_array_size)) + ".trl";
- string trail_file_path = join_file_paths(state->filedir, trail_file_name);
+ string trail_file_path = join_file_paths(state->marker_pack_root_directory, trail_file_name);
ofstream trail_data_file(trail_file_path, ios::binary);
diff --git a/xml_converter/src/packaging_protobin.cpp b/xml_converter/src/packaging_protobin.cpp
index 337c74ef..94cd27f8 100644
--- a/xml_converter/src/packaging_protobin.cpp
+++ b/xml_converter/src/packaging_protobin.cpp
@@ -1,5 +1,6 @@
#include "packaging_protobin.hpp"
+#include
#include
#include