using std::cerr;
using std::cout;
using std::runtime_error;
-using boost::shared_ptr;
+using std::shared_ptr;
using boost::optional;
using boost::function;
}
boost::filesystem::path
-shared_path ()
+resources_path ()
{
- char const * p = getenv ("DCPOMATIC_LINUX_SHARE_PREFIX");
- if (p) {
- return p;
- }
- return boost::filesystem::canonical (LINUX_SHARE_PREFIX);
+ return directory_containing_executable().parent_path() / "share" / "dcpomatic2";
+}
+
+
+boost::filesystem::path
+xsd_path ()
+{
+ return boost::filesystem::canonical(LINUX_SHARE_PREFIX) / "libdcp" / "xsd";
}
+
+boost::filesystem::path
+tags_path ()
+{
+ return boost::filesystem::canonical(LINUX_SHARE_PREFIX) / "libdcp" / "tags";
+}
+
+
void
run_ffprobe (boost::filesystem::path content, boost::filesystem::path out)
{
return getenv("HOME");
}
-string
-command_and_read (string cmd)
-{
- FILE* pipe = popen (cmd.c_str(), "r");
- if (!pipe) {
- throw runtime_error ("popen failed");
- }
-
- string result;
- char buffer[128];
- try {
- while (fgets(buffer, sizeof(buffer), pipe)) {
- result += buffer;
- }
- } catch (...) {
- pclose (pipe);
- throw;
- }
-
- pclose (pipe);
- return result;
-}
-
/** @return true if this process is a 32-bit one running on a 64-bit-capable OS */
bool
running_32_on_64 ()
}
}
+
+bool PrivilegeEscalator::test = false;
+
PrivilegeEscalator::~PrivilegeEscalator ()
{
- unprivileged ();
+ if (!test) {
+ unprivileged ();
+ }
}
PrivilegeEscalator::PrivilegeEscalator ()
{
- int const r = seteuid(0);
- if (r < 0) {
- throw PrivilegeError (String::compose("seteuid() call failed with %1", errno));
+ if (!test) {
+ int const r = seteuid(0);
+ if (r < 0) {
+ throw PrivilegeError (String::compose("seteuid() call failed with %1", errno));
+ }
}
}
}
+string
+dcpomatic::get_process_id ()
+{
+ return dcp::raw_convert<string>(getpid());
+}