add possibility to import tags from external app, e.g. tmsu
This commit is contained in:
@@ -146,6 +146,13 @@ ConfSimple::ConfSimple(int readonly, bool tildexp)
|
||||
status = readonly ? STATUS_RO : STATUS_RW;
|
||||
}
|
||||
|
||||
void ConfSimple::reparse(const string& d)
|
||||
{
|
||||
clear();
|
||||
stringstream input(d, ios::in);
|
||||
parseinput(input);
|
||||
}
|
||||
|
||||
ConfSimple::ConfSimple(const string& d, int readonly, bool tildexp)
|
||||
: dotildexpand(tildexp), m_fmtime(0), m_holdWrites(false)
|
||||
{
|
||||
|
||||
@@ -158,6 +158,16 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Clear, then reparse from string */
|
||||
void reparse(const string& in);
|
||||
|
||||
/** Clear all content */
|
||||
void clear()
|
||||
{
|
||||
m_submaps.clear();
|
||||
m_order.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value for named parameter, from specified subsection (looks in
|
||||
* global space if sk is empty).
|
||||
|
||||
+19
-4
@@ -242,7 +242,7 @@ inline void ExecCmd::dochild(const string &cmd, const char **argv,
|
||||
|
||||
execve(cmd.c_str(), (char *const*)argv, (char *const*)envv);
|
||||
// Hu ho
|
||||
LOGERR(("ExecCmd::doexec: execvp(%s) failed. errno %d\n", cmd.c_str(),
|
||||
LOGERR(("ExecCmd::doexec: execve(%s) failed. errno %d\n", cmd.c_str(),
|
||||
errno));
|
||||
_exit(127);
|
||||
}
|
||||
@@ -634,6 +634,18 @@ bool ExecCmd::maybereap(int *status)
|
||||
}
|
||||
}
|
||||
|
||||
// Static
|
||||
bool ExecCmd::backtick(const std::vector<std::string> cmd, std::string& out)
|
||||
{
|
||||
vector<string>::const_iterator it = cmd.begin();
|
||||
it++;
|
||||
vector<string> args(it, cmd.end());
|
||||
ExecCmd mexec;
|
||||
int status = mexec.doexec(*cmd.begin(), args, 0, &out);
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
/// ReExec class methods ///////////////////////////////////////////////////
|
||||
ReExec::ReExec(int argc, char *args[])
|
||||
{
|
||||
init(argc, args);
|
||||
@@ -747,18 +759,21 @@ void ReExec::reexec()
|
||||
execvp(m_argv[0].c_str(), (char *const*)argv);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#else // TEST
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include "debuglog.h"
|
||||
#include "cancelcheck.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "cancelcheck.h"
|
||||
#include "execmd.h"
|
||||
|
||||
static int op_flags;
|
||||
|
||||
@@ -178,6 +178,14 @@ class ExecCmd {
|
||||
*/
|
||||
static bool which(const string& cmd, string& exe, const char* path = 0);
|
||||
|
||||
/**
|
||||
* Execute command and return stdout output in a string
|
||||
* @param cmd input: command and args
|
||||
* @param out output: what the command printed
|
||||
* @return true if exec status was 0
|
||||
*/
|
||||
static bool backtick(const std::vector<std::string> cmd, std::string& out);
|
||||
|
||||
friend class ExecCmdRsrc;
|
||||
private:
|
||||
static bool o_useVfork;
|
||||
|
||||
+2
-1
@@ -109,7 +109,7 @@ private:
|
||||
|
||||
typedef RefCntr<TempFileInternal> TempFile;
|
||||
|
||||
/// Temporary directory class
|
||||
/// Temporary directory class. Recursively deleted by destructor.
|
||||
class TempDir {
|
||||
public:
|
||||
TempDir();
|
||||
@@ -117,6 +117,7 @@ public:
|
||||
const char *dirname() {return m_dirname.c_str();}
|
||||
const string &getreason() {return m_reason;}
|
||||
bool ok() {return !m_dirname.empty();}
|
||||
/// Recursively delete contents but not self.
|
||||
bool wipe();
|
||||
private:
|
||||
string m_dirname;
|
||||
|
||||
@@ -225,6 +225,28 @@ public:
|
||||
return m_map;
|
||||
}
|
||||
};
|
||||
template <typename T>
|
||||
class create_vector
|
||||
{
|
||||
private:
|
||||
std::vector<T> m_vector;
|
||||
public:
|
||||
create_vector(const T& val)
|
||||
{
|
||||
m_vector.push_back(val);
|
||||
}
|
||||
|
||||
create_vector<T>& operator()(const T& val)
|
||||
{
|
||||
m_vector.push_back(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator std::vector<T>()
|
||||
{
|
||||
return m_vector;
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(A,B) (((A)<(B)) ? (A) : (B))
|
||||
|
||||
Reference in New Issue
Block a user