diff --git a/browser-plugins/webextension/native-wrapper/CMakeLists.txt b/browser-plugins/webextension/native-wrapper/CMakeLists.txt index df05c11..4186b55 100644 --- a/browser-plugins/webextension/native-wrapper/CMakeLists.txt +++ b/browser-plugins/webextension/native-wrapper/CMakeLists.txt @@ -4,6 +4,7 @@ set(INSTALL_MOZILLA_NMH_DIR "${CMAKE_INSTALL_PREFIX}/${MOZILLA_NMH_DIR}") add_executable(${PROJECT_NAME}_wrapper ${PROJECT_NAME}_wrapper.cpp) +target_link_libraries(${PROJECT_NAME}_wrapper stdc++fs) install(TARGETS ${PROJECT_NAME}_wrapper DESTINATION ${MOZILLA_NMH_DIR}) add_custom_command( diff --git a/browser-plugins/webextension/native-wrapper/remwharead_wrapper.cpp b/browser-plugins/webextension/native-wrapper/remwharead_wrapper.cpp index 4a04478..06a53fa 100644 --- a/browser-plugins/webextension/native-wrapper/remwharead_wrapper.cpp +++ b/browser-plugins/webextension/native-wrapper/remwharead_wrapper.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -26,6 +27,8 @@ using std::cout; using std::uint32_t; using std::system; +namespace fs = std::experimental::filesystem; + const string read_input() { string input; @@ -75,12 +78,36 @@ int launch(const string &args) int main() { - const string args = read_input(); + string args = read_input(); + size_t pos = args.find("TEMPFILE"); + string tmpfile; + + if (pos != string::npos) + { + try + { + tmpfile = fs::temp_directory_path() / "remwharead.html"; + args.replace(pos, 8, tmpfile); + } + catch (const fs::filesystem_error &e) + { + send_message("Could not create temporary file."); + return 3; + } + } + int ret = launch(args); if (ret == 0) { - send_message("Command successful."); + if (!tmpfile.empty()) + { + send_message("FILE:" + tmpfile); + } + else + { + send_message("Command successful."); + } } else {