ofxHTTP icon indicating copy to clipboard operation
ofxHTTP copied to clipboard

path extension syntax

Open themancalledjakob opened this issue 2 years ago • 0 comments

OS: Ubuntu 20.04 gcc: 9.3.0

When compiling with -std=c++17 and OF_USING_STD_FS=1 I get

openFrameworks/addons/ofxHTTP/libs/ofxHTTP/src/PostRoute.cpp:312:39: error: ‘extension’ is not a member of ‘std::filesystem’
  312 |                 p += std::filesystem::extension(originalFilename);

Adjusting the syntax as found in cppreference fixes it:

diff --git a/libs/ofxHTTP/src/PostRoute.cpp b/libs/ofxHTTP/src/PostRoute.cpp
index 942b6af..2872110 100644
--- a/libs/ofxHTTP/src/PostRoute.cpp
+++ b/libs/ofxHTTP/src/PostRoute.cpp
@@ -308,7 +308,7 @@ void PostRouteFileHandler::handlePart(const Poco::Net::MessageHeader& header,
                 
                 std::filesystem::path p = uploadFolder;
                 p /= uniqueFilename;
-                p += std::filesystem::extension(originalFilename);
+                p += std::filesystem::path(originalFilename).extension();

Apparently this was only added in cpp17, but the "new" syntax also works for me when compiling without these flags by the way. I'm not entirely sure, but I suspect it's supported when boost or std experimental filesystem is used...

I forked the repository here with the potential fix: https://github.com/themancalledjakob/ofxHTTP/tree/feature-cpp17

But I hesitate with a PR, since I'm not sure if it breaks anything. So far I only tested on my machine.

themancalledjakob avatar Dec 02 '21 07:12 themancalledjakob