diff --git a/Makefile b/Makefile index 0deab5a..f579866 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ INCLUDES := inc inc/ui inc/fs inc/gfx EXEFS_SRC := exefs_src APP_TITLE := JKSV APP_AUTHOR := JK -APP_VERSION := 07.10.2023 +APP_VERSION := 07.25.2024 ROMFS := romfs ICON := icon.jpg diff --git a/inc/data.h b/inc/data.h index 603cde1..e93366d 100644 --- a/inc/data.h +++ b/inc/data.h @@ -8,8 +8,8 @@ #include "gfx.h" #define BLD_MON 07 -#define BLD_DAY 10 -#define BLD_YEAR 2023 +#define BLD_DAY 25 +#define BLD_YEAR 2024 namespace data { diff --git a/inc/webdav.h b/inc/webdav.h index bb25a99..3db44b9 100644 --- a/inc/webdav.h +++ b/inc/webdav.h @@ -48,5 +48,6 @@ namespace rfs { std::string getDirID(const std::string& dirName, const std::string& parentId); std::vector getListWithParent(const std::string& _parent); + std::string getDisplayNameFromURL(const std::string &url); }; } diff --git a/src/webdav.cpp b/src/webdav.cpp index ac8b05c..da9b5f0 100644 --- a/src/webdav.cpp +++ b/src/webdav.cpp @@ -281,6 +281,9 @@ std::vector rfs::WebDav::parseXMLResponse(const std::string& xml) tinyxml2::XMLElement* displaynameElem = propElem->FirstChildElement((nsPrefix + "displayname").c_str()); if (displaynameElem) { item.name = displaynameElem->GetText(); + } else { + // Fallback to name from href + item.name = getDisplayNameFromURL(item.id); } tinyxml2::XMLElement* resourcetypeElem = propElem->FirstChildElement((nsPrefix + "resourcetype").c_str()); @@ -311,3 +314,26 @@ std::vector rfs::WebDav::parseXMLResponse(const std::string& xml) return items; } + +// Function to extract and URL decode the filename from the URL +std::string rfs::WebDav::getDisplayNameFromURL(const std::string &url) { + // Find the position of the last '/' + size_t pos = url.find_last_of('/'); + if (pos == std::string::npos) { + // If '/' is not found, return the whole URL as it is + return url; + } + + // Extract the filename from the URL + std::string encodedFilename = url.substr(pos + 1); + + // URL decode the filename + int outlength; + char *decodedFilename = curl_easy_unescape(curl, encodedFilename.c_str(), encodedFilename.length(), &outlength); + std::string result(decodedFilename, outlength); + + // Free the memory allocated by curl_easy_unescape + curl_free(decodedFilename); + + return result; +}