WebExtension: Native wrapper: replace TEMPFILE with file path,
continuous-integration/drone/push Build was killed
Details
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:
parent
7d659e50c5
commit
c70414114c
|
@ -4,6 +4,7 @@ set(INSTALL_MOZILLA_NMH_DIR
|
||||||
"${CMAKE_INSTALL_PREFIX}/${MOZILLA_NMH_DIR}")
|
"${CMAKE_INSTALL_PREFIX}/${MOZILLA_NMH_DIR}")
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}_wrapper ${PROJECT_NAME}_wrapper.cpp)
|
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})
|
install(TARGETS ${PROJECT_NAME}_wrapper DESTINATION ${MOZILLA_NMH_DIR})
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <experimental/filesystem>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
@ -26,6 +27,8 @@ using std::cout;
|
||||||
using std::uint32_t;
|
using std::uint32_t;
|
||||||
using std::system;
|
using std::system;
|
||||||
|
|
||||||
|
namespace fs = std::experimental::filesystem;
|
||||||
|
|
||||||
const string read_input()
|
const string read_input()
|
||||||
{
|
{
|
||||||
string input;
|
string input;
|
||||||
|
@ -75,12 +78,36 @@ int launch(const string &args)
|
||||||
|
|
||||||
int main()
|
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);
|
int ret = launch(args);
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
send_message("Command successful.");
|
if (!tmpfile.empty())
|
||||||
|
{
|
||||||
|
send_message("FILE:" + tmpfile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
send_message("Command successful.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue