summaryrefslogtreecommitdiff
path: root/src/lib/cross_windows.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-06-03 12:21:28 +0200
committerCarl Hetherington <cth@carlh.net>2020-06-04 01:20:11 +0200
commit7552a04c443c9c641ac580585f6d88900bf84d04 (patch)
tree7a3d4e6d454279b8d43e37d2cd4ae3d956316275 /src/lib/cross_windows.cc
parent816872f9ddf1251f29fe51594401ddd4f4d89c59 (diff)
Clean up handling of paths relative to the executable.
Diffstat (limited to 'src/lib/cross_windows.cc')
-rw-r--r--src/lib/cross_windows.cc34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc
index 8ccc790d6..d732e9fe5 100644
--- a/src/lib/cross_windows.cc
+++ b/src/lib/cross_windows.cc
@@ -127,8 +127,7 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out)
}
wchar_t dir[512];
- GetModuleFileName (GetModuleHandle (0), dir, sizeof (dir));
- PathRemoveFileSpec (dir);
+ MultiByteToWideChar (CP_UTF8, 0, directory_containing_executable().string().c_str(), -1, dir, sizeof(dir));
SetCurrentDirectory (dir);
STARTUPINFO startup_info;
@@ -185,32 +184,37 @@ mount_info ()
return m;
}
-static boost::filesystem::path
-executable_path ()
+
+boost::filesystem::path
+directory_containing_executable ()
{
return boost::dll::program_location().parent_path();
}
+
boost::filesystem::path
shared_path ()
{
- return executable_path().parent_path();
+ return directory_containing_executable().parent_path();
}
+
boost::filesystem::path
openssl_path ()
{
- return executable_path() / "openssl.exe";
+ return directory_containing_executable() / "openssl.exe";
}
+
#ifdef DCPOMATIC_DISK
boost::filesystem::path
disk_writer_path ()
{
- return executable_path() / "dcpomatic2_disk_writer.exe";
+ return directory_containing_executable() / "dcpomatic2_disk_writer.exe";
}
#endif
+
/* Apparently there is no way to create an ofstream using a UTF-8
filename under Windows. We are hence reduced to using fopen
with this wrapper.
@@ -246,10 +250,11 @@ Waker::~Waker ()
}
+
void
-start_tool (boost::filesystem::path dcpomatic, string executable, string)
+start_tool (string executable)
{
- boost::filesystem::path batch = dcpomatic.parent_path() / executable;
+ boost::filesystem::path batch = directory_containing_executable() / executable;
STARTUPINFO startup_info;
ZeroMemory (&startup_info, sizeof (startup_info));
@@ -263,18 +268,21 @@ start_tool (boost::filesystem::path dcpomatic, string executable, string)
CreateProcess (0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info);
}
+
void
-start_batch_converter (boost::filesystem::path dcpomatic)
+start_batch_converter ()
{
- start_tool (dcpomatic, "dcpomatic2_batch", "DCP-o-matic\\ 2\\ Batch\\ Converter.app");
+ start_tool ("dcpomatic2_batch");
}
+
void
-start_player (boost::filesystem::path dcpomatic)
+start_player ()
{
- start_tool (dcpomatic, "dcpomatic2_player", "DCP-o-matic\\ 2\\ Player.app");
+ start_tool ("dcpomatic2_player");
}
+
uint64_t
thread_id ()
{