WebExtension: Native wrapper: replace TEMPFILE with file path,
continuous-integration/drone/push Build was killed Details

And return it. In preparation for a “View database” feature in the
WebExtension.
This commit is contained in:
tastytea 2019-05-26 18:02:47 +02:00
parent 7d659e50c5
commit c70414114c
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 30 additions and 2 deletions

View File

@ -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(

View File

@ -16,6 +16,7 @@
#include <string>
#include <iostream>
#include <experimental/filesystem>
#include <cstdint>
#include <cstdlib>
#include <sys/wait.h>
@ -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
{