5454#endif
5555
5656#include " filesystem_stream.h"
57- #include " base64.hpp "
57+ #include " base64.h "
5858
59- namespace { // Anonymous namespace
59+ namespace {
6060
6161 struct DataUriResult {
6262 std::string_view mime_type;
@@ -68,7 +68,7 @@ namespace { // Anonymous namespace
6868 if (!StartsWith (uri, " data:" )) {
6969 return std::nullopt ;
7070 }
71- // ... (rest of the function is the same)
71+
7272 auto header_end = uri.find (' ,' );
7373 if (header_end == std::string_view::npos) return std::nullopt ;
7474 auto header = uri.substr (5 , header_end - 5 );
@@ -82,13 +82,7 @@ namespace { // Anonymous namespace
8282 result.mime_type = header;
8383 }
8484 if (result.is_base64 ) {
85- try {
86- result.data = base64::decode_into<std::vector<unsigned char >>(data_payload.begin (), data_payload.end ());
87- }
88- catch (const std::exception& e) {
89- Output::Warning (" Base64 decoding failed: {}" , e.what ());
90- return std::nullopt ;
91- }
85+ result.data = base64::decode_into<std::vector<unsigned char >>(data_payload.begin (), data_payload.end ());
9286 }
9387 else {
9488 result.data .assign (data_payload.begin (), data_payload.end ());
@@ -466,11 +460,11 @@ int FileFinder::GetSavegames() {
466460}
467461
468462std::string find_generic (const DirectoryTree::Args& args) {
469- // *** NEW CENTRALIZED LOGIC ***
463+ // *** DATA URI LOGIC ***
470464 if (StartsWith (args.path , " data:" )) {
471465 return std::string (args.path ); // The URI is its own "path"
472466 }
473- // *** END OF NEW LOGIC ***
467+ // *** END OF DATA URI LOGIC ***
474468
475469 if (!Tr::GetCurrentTranslationId ().empty ()) {
476470 auto tr_fs = Tr::GetCurrentTranslationFilesystem ();
@@ -522,7 +516,7 @@ std::string FileFinder::FindFont(std::string_view name) {
522516}
523517
524518Filesystem_Stream::InputStream open_generic (std::string_view dir, std::string_view name, DirectoryTree::Args& args) {
525- // *** NEW CENTRALIZED LOGIC ***
519+ // *** DATA URI LOGIC ***
526520 // Check the 'name' part first, as it's the most likely place for a data URI.
527521 if (StartsWith (name, " data:" )) {
528522 auto parsed_result = parse_data_uri (name);
@@ -547,7 +541,7 @@ Filesystem_Stream::InputStream open_generic(std::string_view dir, std::string_vi
547541 return Filesystem_Stream::InputStream (nullptr , " " ); // Return an invalid stream
548542 }
549543 }
550- // *** END OF NEW LOGIC ***
544+ // *** END OF DATA URI LOGIC ***
551545
552546 if (!Tr::GetCurrentTranslationId ().empty ()) {
553547 auto tr_fs = Tr::GetCurrentTranslationFilesystem ();
0 commit comments