summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-01-21 02:33:24 +0100
committerCarl Hetherington <cth@carlh.net>2025-01-21 02:33:24 +0100
commit4c905330c2052cd77be09d9deb301f1fcf4b81f2 (patch)
tree9f3474d3df0d8000e30b2c427123b3745271fb62 /src
parent7b262ed5fe757291f95435b9c161dda5f6e8bb49 (diff)
White space: cross{_osx,_windows,_common}.cc cross.h
Diffstat (limited to 'src')
-rw-r--r--src/lib/cross.h68
-rw-r--r--src/lib/cross_common.cc16
-rw-r--r--src/lib/cross_osx.cc124
-rw-r--r--src/lib/cross_unix.cc22
-rw-r--r--src/lib/cross_windows.cc222
5 files changed, 226 insertions, 226 deletions
diff --git a/src/lib/cross.h b/src/lib/cross.h
index bb1cc91db..4773e2cb9 100644
--- a/src/lib/cross.h
+++ b/src/lib/cross.h
@@ -42,33 +42,33 @@
class Log;
struct AVIOContext;
-extern void dcpomatic_sleep_seconds (int);
-extern void dcpomatic_sleep_milliseconds (int);
-extern std::string cpu_info ();
+extern void dcpomatic_sleep_seconds(int);
+extern void dcpomatic_sleep_milliseconds(int);
+extern std::string cpu_info();
extern void run_ffprobe(boost::filesystem::path content, boost::filesystem::path out, bool err = true, std::string args = {});
-extern std::list<std::pair<std::string, std::string>> mount_info ();
-extern boost::filesystem::path openssl_path ();
-extern void make_foreground_application ();
+extern std::list<std::pair<std::string, std::string>> mount_info();
+extern boost::filesystem::path openssl_path();
+extern void make_foreground_application();
#ifdef DCPOMATIC_DISK
-extern boost::filesystem::path disk_writer_path ();
+extern boost::filesystem::path disk_writer_path();
#endif
#ifdef DCPOMATIC_WINDOWS
-extern void maybe_open_console ();
+extern void maybe_open_console();
#endif
-extern boost::filesystem::path resources_path ();
-extern boost::filesystem::path libdcp_resources_path ();
-extern void start_batch_converter ();
-extern void start_player ();
-extern uint64_t thread_id ();
-extern int avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags);
-extern boost::filesystem::path home_directory ();
-extern bool running_32_on_64 ();
-extern void unprivileged ();
-extern boost::filesystem::path config_path (boost::optional<std::string> version);
-extern boost::filesystem::path directory_containing_executable ();
-extern bool show_in_file_manager (boost::filesystem::path dir, boost::filesystem::path select);
+extern boost::filesystem::path resources_path();
+extern boost::filesystem::path libdcp_resources_path();
+extern void start_batch_converter();
+extern void start_player();
+extern uint64_t thread_id();
+extern int avio_open_boost(AVIOContext** s, boost::filesystem::path file, int flags);
+extern boost::filesystem::path home_directory();
+extern bool running_32_on_64();
+extern void unprivileged();
+extern boost::filesystem::path config_path(boost::optional<std::string> version);
+extern boost::filesystem::path directory_containing_executable();
+extern bool show_in_file_manager(boost::filesystem::path dir, boost::filesystem::path select);
namespace dcpomatic {
- std::string get_process_id ();
+ std::string get_process_id();
}
@@ -81,10 +81,10 @@ namespace dcpomatic {
class Waker
{
public:
- Waker ();
- ~Waker ();
+ Waker();
+ ~Waker();
- void nudge ();
+ void nudge();
private:
boost::mutex _mutex;
@@ -106,7 +106,7 @@ public:
, _model(model)
{}
#else
- Drive (std::string device, std::vector<boost::filesystem::path> mount_points, uint64_t size, boost::optional<std::string> vendor, boost::optional<std::string> model)
+ Drive(std::string device, std::vector<boost::filesystem::path> mount_points, uint64_t size, boost::optional<std::string> vendor, boost::optional<std::string> model)
: _device(device)
, _mount_points(mount_points)
, _size(size)
@@ -115,17 +115,17 @@ public:
{}
#endif
- explicit Drive (std::string);
+ explicit Drive(std::string);
- std::string as_xml () const;
+ std::string as_xml() const;
- std::string description () const;
+ std::string description() const;
- std::string device () const {
+ std::string device() const {
return _device;
}
- bool mounted () const {
+ bool mounted() const {
#ifdef DCPOMATIC_OSX
return _mounted;
#else
@@ -133,12 +133,12 @@ public:
#endif
}
- std::string log_summary () const;
+ std::string log_summary() const;
/** Unmount any mounted partitions on a drive.
* @return true on success, false on failure.
*/
- bool unmount ();
+ bool unmount();
#ifdef DCPOMATIC_OSX
void set_mounted() {
@@ -146,7 +146,7 @@ public:
}
#endif
- static std::vector<Drive> get ();
+ static std::vector<Drive> get();
private:
std::string _device;
@@ -162,7 +162,7 @@ private:
};
-void disk_write_finished ();
+void disk_write_finished();
class ArgFixer
diff --git a/src/lib/cross_common.cc b/src/lib/cross_common.cc
index b6df88837..c3741df03 100644
--- a/src/lib/cross_common.cc
+++ b/src/lib/cross_common.cc
@@ -40,16 +40,16 @@ using std::vector;
using boost::optional;
-Drive::Drive (string xml)
+Drive::Drive(string xml)
{
cxml::Document doc;
- doc.read_string (xml);
+ doc.read_string(xml);
_device = doc.string_child("Device");
#ifdef DCPOMATIC_OSX
_mounted = doc.bool_child("Mounted");
#else
for (auto i: doc.node_children("MountPoint")) {
- _mount_points.push_back (i->content());
+ _mount_points.push_back(i->content());
}
#endif
_size = doc.number_child<uint64_t>("Size");
@@ -59,10 +59,10 @@ Drive::Drive (string xml)
string
-Drive::as_xml () const
+Drive::as_xml() const
{
xmlpp::Document doc;
- auto root = doc.create_root_node ("Drive");
+ auto root = doc.create_root_node("Drive");
cxml::add_text_child(root, "Device", _device);
#ifdef DCPOMATIC_OSX
cxml::add_text_child(root, "Mounted", _mounted ? "1" : "0");
@@ -84,7 +84,7 @@ Drive::as_xml () const
string
-Drive::description () const
+Drive::description() const
{
char gb[64];
snprintf(gb, 64, "%.1f", _size / 1000000000.0);
@@ -109,7 +109,7 @@ Drive::description () const
string
-Drive::log_summary () const
+Drive::log_summary() const
{
string mp;
#ifdef DCPOMATIC_OSX
@@ -126,7 +126,7 @@ Drive::log_summary () const
if (_mount_points.empty()) {
mp = "[none]";
} else {
- mp = mp.substr (0, mp.length() - 1);
+ mp = mp.substr(0, mp.length() - 1);
}
#endif
diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc
index 8ae8cf087..350287e75 100644
--- a/src/lib/cross_osx.cc
+++ b/src/lib/cross_osx.cc
@@ -68,12 +68,12 @@ using std::function;
/** @return A string of CPU information (model name etc.) */
string
-cpu_info ()
+cpu_info()
{
string info;
char buffer[64];
- size_t N = sizeof (buffer);
+ size_t N = sizeof(buffer);
if (sysctlbyname("machdep.cpu.brand_string", buffer, &N, 0, 0) == 0) {
info = buffer;
}
@@ -83,21 +83,21 @@ cpu_info ()
boost::filesystem::path
-directory_containing_executable ()
+directory_containing_executable()
{
return dcp::filesystem::canonical(boost::dll::program_location()).parent_path();
}
boost::filesystem::path
-resources_path ()
+resources_path()
{
return directory_containing_executable().parent_path() / "Resources";
}
boost::filesystem::path
-libdcp_resources_path ()
+libdcp_resources_path()
{
return resources_path();
}
@@ -106,7 +106,7 @@ libdcp_resources_path ()
void
run_ffprobe(boost::filesystem::path content, boost::filesystem::path out, bool err, string args)
{
- auto path = directory_containing_executable () / "ffprobe";
+ auto path = directory_containing_executable() / "ffprobe";
if (!dcp::filesystem::exists(path)) {
/* This is a hack but we need ffprobe during tests */
path = "/Users/ci/workspace/bin/ffprobe";
@@ -114,21 +114,21 @@ run_ffprobe(boost::filesystem::path content, boost::filesystem::path out, bool e
string const redirect = err ? "2>" : ">";
auto const ffprobe = String::compose("\"%1\" %2 \"%3\" %4 \"%5\"", path, args.empty() ? " " : args, content.string(), redirect, out.string());
- LOG_GENERAL (N_("Probing with %1"), ffprobe);
- system (ffprobe.c_str());
+ LOG_GENERAL(N_("Probing with %1"), ffprobe);
+ system(ffprobe.c_str());
}
list<pair<string, string>>
-mount_info ()
+mount_info()
{
return {};
}
boost::filesystem::path
-openssl_path ()
+openssl_path()
{
return directory_containing_executable() / "openssl";
}
@@ -137,7 +137,7 @@ openssl_path ()
#ifdef DCPOMATIC_DISK
/* Note: this isn't actually used at the moment as the disk writer is started as a service */
boost::filesystem::path
-disk_writer_path ()
+disk_writer_path()
{
return directory_containing_executable() / "dcpomatic2_disk_writer";
}
@@ -145,28 +145,28 @@ disk_writer_path ()
void
-Waker::nudge ()
+Waker::nudge()
{
}
-Waker::Waker ()
+Waker::Waker()
{
- boost::mutex::scoped_lock lm (_mutex);
- IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id);
+ boost::mutex::scoped_lock lm(_mutex);
+ IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR("Encoding DCP"), &_assertion_id);
}
-Waker::~Waker ()
+Waker::~Waker()
{
- boost::mutex::scoped_lock lm (_mutex);
- IOPMAssertionRelease (_assertion_id);
+ boost::mutex::scoped_lock lm(_mutex);
+ IOPMAssertionRelease(_assertion_id);
}
void
-start_tool (string executable, string app)
+start_tool(string executable, string app)
{
boost::algorithm::replace_all(app, " ", "\\ ");
@@ -179,11 +179,11 @@ start_tool (string executable, string app)
exe_path /= "MacOS";
exe_path /= executable;
- pid_t pid = fork ();
+ pid_t pid = fork();
if (pid == 0) {
- LOG_GENERAL ("start_tool %1 %2 with path %3", executable, app, exe_path.string());
- int const r = system (exe_path.string().c_str());
- exit (WEXITSTATUS (r));
+ LOG_GENERAL("start_tool %1 %2 with path %3", executable, app, exe_path.string());
+ int const r = system(exe_path.string().c_str());
+ exit(WEXITSTATUS(r));
} else if (pid == -1) {
LOG_ERROR_NC("Fork failed in start_tool");
}
@@ -191,14 +191,14 @@ start_tool (string executable, string app)
void
-start_batch_converter ()
+start_batch_converter()
{
start_tool("dcpomatic2_batch", variant::dcpomatic_batch_converter_app());
}
void
-start_player ()
+start_player()
{
start_tool("dcpomatic2_player", variant::dcpomatic_player_app());
}
@@ -219,39 +219,39 @@ struct OSXDisk
static optional<string>
-get_vendor (CFDictionaryRef& description)
+get_vendor(CFDictionaryRef& description)
{
- void const* str = CFDictionaryGetValue (description, kDADiskDescriptionDeviceVendorKey);
+ void const* str = CFDictionaryGetValue(description, kDADiskDescriptionDeviceVendorKey);
if (!str) {
return {};
}
- auto c_str = CFStringGetCStringPtr ((CFStringRef) str, kCFStringEncodingUTF8);
+ auto c_str = CFStringGetCStringPtr((CFStringRef) str, kCFStringEncodingUTF8);
if (!c_str) {
return {};
}
- string s (c_str);
- boost::algorithm::trim (s);
+ string s(c_str);
+ boost::algorithm::trim(s);
return s;
}
static optional<string>
-get_model (CFDictionaryRef& description)
+get_model(CFDictionaryRef& description)
{
- void const* str = CFDictionaryGetValue (description, kDADiskDescriptionDeviceModelKey);
+ void const* str = CFDictionaryGetValue(description, kDADiskDescriptionDeviceModelKey);
if (!str) {
return {};
}
- auto c_str = CFStringGetCStringPtr ((CFStringRef) str, kCFStringEncodingUTF8);
+ auto c_str = CFStringGetCStringPtr((CFStringRef) str, kCFStringEncodingUTF8);
if (!c_str) {
return {};
}
- string s (c_str);
- boost::algorithm::trim (s);
+ string s(c_str);
+ boost::algorithm::trim(s);
return s;
}
@@ -260,7 +260,7 @@ static
bool
is_mounted(CFDictionaryRef& description)
{
- auto volume_path_key = (CFURLRef) CFDictionaryGetValue (description, kDADiskDescriptionVolumePathKey);
+ auto volume_path_key = (CFURLRef) CFDictionaryGetValue(description, kDADiskDescriptionVolumePathKey);
if (!volume_path_key) {
return false;
}
@@ -283,9 +283,9 @@ get_bool(CFDictionaryRef& description, void const* key)
static void
-disk_appeared (DADiskRef disk, void* context)
+disk_appeared(DADiskRef disk, void* context)
{
- auto bsd_name = DADiskGetBSDName (disk);
+ auto bsd_name = DADiskGetBSDName(disk);
if (!bsd_name) {
LOG_DISK_NC("Disk with no BSDName appeared");
return;
@@ -298,15 +298,15 @@ disk_appeared (DADiskRef disk, void* context)
this_disk.device = string("/dev/") + this_disk.bsd_name;
LOG_DISK("Device is %1", this_disk.device);
- CFDictionaryRef description = DADiskCopyDescription (disk);
+ CFDictionaryRef description = DADiskCopyDescription(disk);
- this_disk.vendor = get_vendor (description);
- this_disk.model = get_model (description);
+ this_disk.vendor = get_vendor(description);
+ this_disk.model = get_model(description);
LOG_DISK("Vendor/model: %1 %2", this_disk.vendor.get_value_or("[none]"), this_disk.model.get_value_or("[none]"));
this_disk.mounted = is_mounted(description);
- auto media_size_cstr = CFDictionaryGetValue (description, kDADiskDescriptionMediaSizeKey);
+ auto media_size_cstr = CFDictionaryGetValue(description, kDADiskDescriptionMediaSizeKey);
if (!media_size_cstr) {
LOG_DISK_NC("Could not read media size");
return;
@@ -325,15 +325,15 @@ disk_appeared (DADiskRef disk, void* context)
this_disk.mounted ? "mounted" : "not mounted"
);
- CFNumberGetValue ((CFNumberRef) media_size_cstr, kCFNumberLongType, &this_disk.size);
- CFRelease (description);
+ CFNumberGetValue((CFNumberRef) media_size_cstr, kCFNumberLongType, &this_disk.size);
+ CFRelease(description);
reinterpret_cast<vector<OSXDisk>*>(context)->push_back(this_disk);
}
vector<Drive>
-Drive::get ()
+Drive::get()
{
using namespace boost::algorithm;
vector<OSXDisk> disks;
@@ -347,10 +347,10 @@ Drive::get ()
LOG_DISK_NC("Drive::get() has session");
- DARegisterDiskAppearedCallback (session, NULL, disk_appeared, &disks);
- auto run_loop = CFRunLoopGetCurrent ();
- DASessionScheduleWithRunLoop (session, run_loop, kCFRunLoopDefaultMode);
- CFRunLoopStop (run_loop);
+ DARegisterDiskAppearedCallback(session, NULL, disk_appeared, &disks);
+ auto run_loop = CFRunLoopGetCurrent();
+ DASessionScheduleWithRunLoop(session, run_loop, kCFRunLoopDefaultMode);
+ CFRunLoopStop(run_loop);
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.05, 0);
DAUnregisterCallback(session, (void *) disk_appeared, &disks);
CFRelease(session);
@@ -396,10 +396,10 @@ Drive::get ()
boost::filesystem::path
-config_path (optional<string> version)
+config_path(optional<string> version)
{
boost::filesystem::path p;
- p /= g_get_home_dir ();
+ p /= g_get_home_dir();
p /= "Library";
p /= "Preferences";
p /= "com.dcpomatic";
@@ -433,7 +433,7 @@ void done_callback(DADiskRef, DADissenterRef dissenter, void* context)
bool
-Drive::unmount ()
+Drive::unmount()
{
LOG_DISK_NC("Unmount operation started");
@@ -449,11 +449,11 @@ Drive::unmount ()
LOG_DISK("Requesting unmount of %1 from %2", _device, thread_id());
UnmountState state;
DADiskUnmount(disk, kDADiskUnmountOptionWhole, &done_callback, &state);
- CFRelease (disk);
+ CFRelease(disk);
- CFRunLoopRef run_loop = CFRunLoopGetCurrent ();
- DASessionScheduleWithRunLoop (session, run_loop, kCFRunLoopDefaultMode);
- CFRunLoopStop (run_loop);
+ CFRunLoopRef run_loop = CFRunLoopGetCurrent();
+ DASessionScheduleWithRunLoop(session, run_loop, kCFRunLoopDefaultMode);
+ CFRunLoopStop(run_loop);
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 5, 0);
CFRelease(session);
@@ -467,27 +467,27 @@ Drive::unmount ()
void
-disk_write_finished ()
+disk_write_finished()
{
}
void
-make_foreground_application ()
+make_foreground_application()
{
ProcessSerialNumber serial;
LIBDCP_DISABLE_WARNINGS
- GetCurrentProcess (&serial);
+ GetCurrentProcess(&serial);
LIBDCP_ENABLE_WARNINGS
- TransformProcessType (&serial, kProcessTransformToForegroundApplication);
+ TransformProcessType(&serial, kProcessTransformToForegroundApplication);
}
bool
-show_in_file_manager (boost::filesystem::path, boost::filesystem::path select)
+show_in_file_manager(boost::filesystem::path, boost::filesystem::path select)
{
- int r = system (String::compose("open -R \"%1\"", select.string()).c_str());
+ int r = system(String::compose("open -R \"%1\"", select.string()).c_str());
return static_cast<bool>(WEXITSTATUS(r));
}
diff --git a/src/lib/cross_unix.cc b/src/lib/cross_unix.cc
index 0327c8136..154a1811f 100644
--- a/src/lib/cross_unix.cc
+++ b/src/lib/cross_unix.cc
@@ -34,35 +34,35 @@ using std::string;
/** @param s Number of seconds to sleep for */
void
-dcpomatic_sleep_seconds (int s)
+dcpomatic_sleep_seconds(int s)
{
- sleep (s);
+ sleep(s);
}
void
-dcpomatic_sleep_milliseconds (int ms)
+dcpomatic_sleep_milliseconds(int ms)
{
- usleep (ms * 1000);
+ usleep(ms * 1000);
}
uint64_t
-thread_id ()
+thread_id()
{
- return (uint64_t) pthread_self ();
+ return (uint64_t) pthread_self();
}
int
-avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags)
+avio_open_boost(AVIOContext** s, boost::filesystem::path file, int flags)
{
- return avio_open (s, file.c_str(), flags);
+ return avio_open(s, file.c_str(), flags);
}
boost::filesystem::path
-home_directory ()
+home_directory()
{
return getenv("HOME");
}
@@ -70,7 +70,7 @@ home_directory ()
/** @return true if this process is a 32-bit one running on a 64-bit-capable OS */
bool
-running_32_on_64 ()
+running_32_on_64()
{
/* I'm assuming nobody does this on Linux/macOS */
return false;
@@ -78,7 +78,7 @@ running_32_on_64 ()
string
-dcpomatic::get_process_id ()
+dcpomatic::get_process_id()
{
return fmt::to_string(getpid());
}
diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc
index 13d52ee3b..ad71a3849 100644
--- a/src/lib/cross_windows.cc
+++ b/src/lib/cross_windows.cc
@@ -77,33 +77,33 @@ static std::vector<pair<HANDLE, string>> locked_volumes;
/** @param s Number of seconds to sleep for */
void
-dcpomatic_sleep_seconds (int s)
+dcpomatic_sleep_seconds(int s)
{
- Sleep (s * 1000);
+ Sleep(s * 1000);
}
void
-dcpomatic_sleep_milliseconds (int ms)
+dcpomatic_sleep_milliseconds(int ms)
{
- Sleep (ms);
+ Sleep(ms);
}
/** @return A string of CPU information (model name etc.) */
string
-cpu_info ()
+cpu_info()
{
string info;
HKEY key;
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, KEY_READ, &key) != ERROR_SUCCESS) {
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, KEY_READ, &key) != ERROR_SUCCESS) {
return info;
}
DWORD type;
DWORD data;
- if (RegQueryValueEx (key, L"ProcessorNameString", 0, &type, 0, &data) != ERROR_SUCCESS) {
+ if (RegQueryValueEx(key, L"ProcessorNameString", 0, &type, 0, &data) != ERROR_SUCCESS) {
return info;
}
@@ -111,15 +111,15 @@ cpu_info ()
return info;
}
- wstring value (data / sizeof (wchar_t), L'\0');
- if (RegQueryValueEx (key, L"ProcessorNameString", 0, 0, reinterpret_cast<LPBYTE> (&value[0]), &data) != ERROR_SUCCESS) {
- RegCloseKey (key);
+ wstring value(data / sizeof(wchar_t), L'\0');
+ if (RegQueryValueEx(key, L"ProcessorNameString", 0, 0, reinterpret_cast<LPBYTE>(&value[0]), &data) != ERROR_SUCCESS) {
+ RegCloseKey(key);
return info;
}
- info = string (value.begin(), value.end());
+ info = string(value.begin(), value.end());
- RegCloseKey (key);
+ RegCloseKey(key);
return info;
}
@@ -129,14 +129,14 @@ void
run_ffprobe(boost::filesystem::path content, boost::filesystem::path out, bool err, string args)
{
SECURITY_ATTRIBUTES security;
- security.nLength = sizeof (security);
+ security.nLength = sizeof(security);
security.bInheritHandle = TRUE;
security.lpSecurityDescriptor = 0;
HANDLE child_out_read;
HANDLE child_out_write;
if (!CreatePipe(&child_out_read, &child_out_write, &security, 0)) {
- LOG_ERROR_NC ("ffprobe call failed (could not CreatePipe)");
+ LOG_ERROR_NC("ffprobe call failed (could not CreatePipe)");
return;
}
@@ -146,11 +146,11 @@ run_ffprobe(boost::filesystem::path content, boost::filesystem::path out, bool e
}
wchar_t dir[512];
- MultiByteToWideChar (CP_UTF8, 0, directory_containing_executable().string().c_str(), -1, dir, sizeof(dir));
+ MultiByteToWideChar(CP_UTF8, 0, directory_containing_executable().string().c_str(), -1, dir, sizeof(dir));
STARTUPINFO startup_info;
- ZeroMemory (&startup_info, sizeof (startup_info));
- startup_info.cb = sizeof (startup_info);
+ ZeroMemory(&startup_info, sizeof(startup_info));
+ startup_info.cb = sizeof(startup_info);
if (err) {
startup_info.hStdError = child_out_write;
} else {
@@ -173,15 +173,15 @@ run_ffprobe(boost::filesystem::path content, boost::filesystem::path out, bool e
wcscat(command, L"\"");
PROCESS_INFORMATION process_info;
- ZeroMemory (&process_info, sizeof (process_info));
- if (!CreateProcess (0, command, 0, 0, TRUE, CREATE_NO_WINDOW, 0, dir, &startup_info, &process_info)) {
- LOG_ERROR_NC (N_("ffprobe call failed (could not CreateProcess)"));
+ ZeroMemory(&process_info, sizeof(process_info));
+ if (!CreateProcess(0, command, 0, 0, TRUE, CREATE_NO_WINDOW, 0, dir, &startup_info, &process_info)) {
+ LOG_ERROR_NC(N_("ffprobe call failed (could not CreateProcess)"));
return;
}
dcp::File o(out, "w");
if (!o) {
- LOG_ERROR_NC (N_("ffprobe call failed (could not create output file)"));
+ LOG_ERROR_NC(N_("ffprobe call failed (could not create output file)"));
return;
}
@@ -198,43 +198,43 @@ run_ffprobe(boost::filesystem::path content, boost::filesystem::path out, bool e
o.close();
- WaitForSingleObject (process_info.hProcess, INFINITE);
- CloseHandle (process_info.hProcess);
- CloseHandle (process_info.hThread);
+ WaitForSingleObject(process_info.hProcess, INFINITE);
+ CloseHandle(process_info.hProcess);
+ CloseHandle(process_info.hThread);
CloseHandle(child_out_read);
}
list<pair<string, string>>
-mount_info ()
+mount_info()
{
return {};
}
boost::filesystem::path
-directory_containing_executable ()
+directory_containing_executable()
{
return boost::dll::program_location().parent_path();
}
boost::filesystem::path
-resources_path ()
+resources_path()
{
return directory_containing_executable().parent_path();
}
boost::filesystem::path
-libdcp_resources_path ()
+libdcp_resources_path()
{
- return resources_path ();
+ return resources_path();
}
boost::filesystem::path
-openssl_path ()
+openssl_path()
{
return directory_containing_executable() / "openssl.exe";
}
@@ -242,7 +242,7 @@ openssl_path ()
#ifdef DCPOMATIC_DISK
boost::filesystem::path
-disk_writer_path ()
+disk_writer_path()
{
return directory_containing_executable() / "dcpomatic2_disk_writer.exe";
}
@@ -250,86 +250,86 @@ disk_writer_path ()
void
-Waker::nudge ()
+Waker::nudge()
{
- boost::mutex::scoped_lock lm (_mutex);
- SetThreadExecutionState (ES_SYSTEM_REQUIRED);
+ boost::mutex::scoped_lock lm(_mutex);
+ SetThreadExecutionState(ES_SYSTEM_REQUIRED);
}
-Waker::Waker ()
+Waker::Waker()
{
}
-Waker::~Waker ()
+Waker::~Waker()
{
}
void
-start_tool (string executable)
+start_tool(string executable)
{
auto batch = directory_containing_executable() / executable;
STARTUPINFO startup_info;
- ZeroMemory (&startup_info, sizeof (startup_info));
- startup_info.cb = sizeof (startup_info);
+ ZeroMemory(&startup_info, sizeof(startup_info));
+ startup_info.cb = sizeof(startup_info);
PROCESS_INFORMATION process_info;
- ZeroMemory (&process_info, sizeof (process_info));
+ ZeroMemory(&process_info, sizeof(process_info));
wchar_t cmd[512];
- MultiByteToWideChar (CP_UTF8, 0, batch.string().c_str(), -1, cmd, sizeof(cmd));
- CreateProcess (0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info);
+ MultiByteToWideChar(CP_UTF8, 0, batch.string().c_str(), -1, cmd, sizeof(cmd));
+ CreateProcess(0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info);
}
void
-start_batch_converter ()
+start_batch_converter()
{
- start_tool ("dcpomatic2_batch");
+ start_tool("dcpomatic2_batch");
}
void
-start_player ()
+start_player()
{
- start_tool ("dcpomatic2_player");
+ start_tool("dcpomatic2_player");
}
uint64_t
-thread_id ()
+thread_id()
{
- return (uint64_t) GetCurrentThreadId ();
+ return (uint64_t) GetCurrentThreadId();
}
static string
-wchar_to_utf8 (wchar_t const * s)
+wchar_to_utf8(wchar_t const * s)
{
int const length = (wcslen(s) + 1) * 2;
std::vector<char> utf8(length);
- WideCharToMultiByte (CP_UTF8, 0, s, -1, utf8.data(), length, 0, 0);
- string u (utf8.data());
+ WideCharToMultiByte(CP_UTF8, 0, s, -1, utf8.data(), length, 0, 0);
+ string u(utf8.data());
return u;
}
int
-avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags)
+avio_open_boost(AVIOContext** s, boost::filesystem::path file, int flags)
{
- return avio_open (s, wchar_to_utf8(file.c_str()).c_str(), flags);
+ return avio_open(s, wchar_to_utf8(file.c_str()).c_str(), flags);
}
void
-maybe_open_console ()
+maybe_open_console()
{
- if (Config::instance()->win32_console ()) {
+ if (Config::instance()->win32_console()) {
AllocConsole();
auto handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -348,7 +348,7 @@ maybe_open_console ()
boost::filesystem::path
-home_directory ()
+home_directory()
{
PWSTR wide_path;
auto result = SHGetKnownFolderPath(FOLDERID_Documents, 0, nullptr, &wide_path);
@@ -366,26 +366,26 @@ home_directory ()
/** @return true if this process is a 32-bit one running on a 64-bit-capable OS */
bool
-running_32_on_64 ()
+running_32_on_64()
{
BOOL p;
- IsWow64Process (GetCurrentProcess(), &p);
+ IsWow64Process(GetCurrentProcess(), &p);
return p;
}
static optional<string>
-get_friendly_name (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data)
+get_friendly_name(HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data)
{
wchar_t buffer[MAX_PATH];
- ZeroMemory (&buffer, sizeof(buffer));
- bool r = SetupDiGetDeviceRegistryPropertyW (
+ ZeroMemory(&buffer, sizeof(buffer));
+ bool r = SetupDiGetDeviceRegistryPropertyW(
device_info, device_info_data, SPDRP_FRIENDLYNAME, 0, reinterpret_cast<PBYTE>(buffer), sizeof(buffer), 0
);
if (!r) {
return optional<string>();
}
- return wchar_to_utf8 (buffer);
+ return wchar_to_utf8(buffer);
}
@@ -395,14 +395,14 @@ static const GUID GUID_DEVICE_INTERFACE_DISK = {
static optional<int>
-get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data)
+get_device_number(HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data)
{
/* Find the Windows path to the device */
SP_DEVICE_INTERFACE_DATA device_interface_data;
device_interface_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
- auto r = SetupDiEnumDeviceInterfaces (device_info, device_info_data, &GUID_DEVICE_INTERFACE_DISK, 0, &device_interface_data);
+ auto r = SetupDiEnumDeviceInterfaces(device_info, device_info_data, &GUID_DEVICE_INTERFACE_DISK, 0, &device_interface_data);
if (!r) {
LOG_DISK("SetupDiEnumDeviceInterfaces failed (%1)", GetLastError());
return optional<int>();
@@ -411,7 +411,7 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data)
/* Find out how much space we need for our SP_DEVICE_INTERFACE_DETAIL_DATA_W */
DWORD size;
r = SetupDiGetDeviceInterfaceDetailW(device_info, &device_interface_data, 0, 0, &size, 0);
- PSP_DEVICE_INTERFACE_DETAIL_DATA_W device_detail_data = static_cast<PSP_DEVICE_INTERFACE_DETAIL_DATA_W> (malloc(size));
+ PSP_DEVICE_INTERFACE_DETAIL_DATA_W device_detail_data = static_cast<PSP_DEVICE_INTERFACE_DETAIL_DATA_W>(malloc(size));
if (!device_detail_data) {
LOG_DISK_NC("malloc failed");
return optional<int>();
@@ -420,23 +420,23 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data)
device_detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
/* And get the path */
- r = SetupDiGetDeviceInterfaceDetailW (device_info, &device_interface_data, device_detail_data, size, &size, 0);
+ r = SetupDiGetDeviceInterfaceDetailW(device_info, &device_interface_data, device_detail_data, size, &size, 0);
if (!r) {
LOG_DISK_NC("SetupDiGetDeviceInterfaceDetailW failed");
- free (device_detail_data);
+ free(device_detail_data);
return optional<int>();
}
/* Open it. We would not be allowed GENERIC_READ access here but specifying 0 for
dwDesiredAccess allows us to query some metadata.
*/
- auto device = CreateFileW (
+ auto device = CreateFileW(
device_detail_data->DevicePath, 0,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0
);
- free (device_detail_data);
+ free(device_detail_data);
if (device == INVALID_HANDLE_VALUE) {
LOG_DISK("CreateFileW failed with %1", GetLastError());
@@ -445,12 +445,12 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data)
/* Get the device number */
STORAGE_DEVICE_NUMBER device_number;
- r = DeviceIoControl (
+ r = DeviceIoControl(
device, IOCTL_STORAGE_GET_DEVICE_NUMBER, 0, 0,
&device_number, sizeof(device_number), &size, 0
);
- CloseHandle (device);
+ CloseHandle(device);
if (!r) {
return {};
@@ -467,7 +467,7 @@ typedef map<int, vector<boost::filesystem::path>> MountPoints;
* to @ref disks.
*/
static void
-add_volume_mount_points (wchar_t* volume, MountPoints& mount_points)
+add_volume_mount_points(wchar_t* volume, MountPoints& mount_points)
{
LOG_DISK("Looking at %1", wchar_to_utf8(volume));
@@ -477,73 +477,73 @@ add_volume_mount_points (wchar_t* volume, MountPoints& mount_points)
if (GetVolumePathNamesForVolumeNameW(volume, volume_path_names, sizeof(volume_path_names) / sizeof(wchar_t), &returned)) {
wchar_t* p = volume_path_names;
while (*p != L'\0') {
- mp.push_back (wchar_to_utf8(p));
- LOG_DISK ("Found mount point %1", wchar_to_utf8(p));
+ mp.push_back(wchar_to_utf8(p));
+ LOG_DISK("Found mount point %1", wchar_to_utf8(p));
p += wcslen(p) + 1;
}
}
/* Strip trailing \ */
- size_t const len = wcslen (volume);
- DCPOMATIC_ASSERT (len > 0);
+ size_t const len = wcslen(volume);
+ DCPOMATIC_ASSERT(len > 0);
volume[len - 1] = L'\0';
- auto handle = CreateFileW (
+ auto handle = CreateFileW(
volume, 0,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0
);
- DCPOMATIC_ASSERT (handle != INVALID_HANDLE_VALUE);
+ DCPOMATIC_ASSERT(handle != INVALID_HANDLE_VALUE);
VOLUME_DISK_EXTENTS extents;
DWORD size;
- BOOL r = DeviceIoControl (handle, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, 0, 0, &extents, sizeof(extents), &size, 0);
- CloseHandle (handle);
+ BOOL r = DeviceIoControl(handle, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, 0, 0, &extents, sizeof(extents), &size, 0);
+ CloseHandle(handle);
if (!r) {
return;
}
- DCPOMATIC_ASSERT (extents.NumberOfDiskExtents == 1);
+ DCPOMATIC_ASSERT(extents.NumberOfDiskExtents == 1);
mount_points[extents.Extents[0].DiskNumber] = mp;
}
MountPoints
-find_mount_points ()
+find_mount_points()
{
MountPoints mount_points;
wchar_t volume_name[512];
- auto volume = FindFirstVolumeW (volume_name, sizeof(volume_name) / sizeof(wchar_t));
+ auto volume = FindFirstVolumeW(volume_name, sizeof(volume_name) / sizeof(wchar_t));
if (volume == INVALID_HANDLE_VALUE) {
return MountPoints();
}
- add_volume_mount_points (volume_name, mount_points);
+ add_volume_mount_points(volume_name, mount_points);
while (true) {
if (!FindNextVolumeW(volume, volume_name, sizeof(volume_name) / sizeof(wchar_t))) {
break;
}
- add_volume_mount_points (volume_name, mount_points);
+ add_volume_mount_points(volume_name, mount_points);
}
- FindVolumeClose (volume);
+ FindVolumeClose(volume);
return mount_points;
}
vector<Drive>
-Drive::get ()
+Drive::get()
{
vector<Drive> drives;
- auto mount_points = find_mount_points ();
+ auto mount_points = find_mount_points();
/* Get a `device information set' containing information about all disks */
- auto device_info = SetupDiGetClassDevsA (&GUID_DEVICE_INTERFACE_DISK, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ auto device_info = SetupDiGetClassDevsA(&GUID_DEVICE_INTERFACE_DISK, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (device_info == INVALID_HANDLE_VALUE) {
- LOG_DISK_NC ("SetupDiClassDevsA failed");
+ LOG_DISK_NC("SetupDiClassDevsA failed");
return drives;
}
@@ -555,21 +555,21 @@ Drive::get ()
if (!SetupDiEnumDeviceInfo(device_info, i, &device_info_data)) {
DWORD e = GetLastError();
if (e != ERROR_NO_MORE_ITEMS) {
- LOG_DISK ("SetupDiEnumDeviceInfo failed (%1)", GetLastError());
+ LOG_DISK("SetupDiEnumDeviceInfo failed (%1)", GetLastError());
}
break;
}
++i;
- auto const friendly_name = get_friendly_name (device_info, &device_info_data);
- auto device_number = get_device_number (device_info, &device_info_data);
+ auto const friendly_name = get_friendly_name(device_info, &device_info_data);
+ auto device_number = get_device_number(device_info, &device_info_data);
if (!device_number) {
continue;
}
string const physical_drive = String::compose("\\\\.\\PHYSICALDRIVE%1", *device_number);
- HANDLE device = CreateFileA (
+ HANDLE device = CreateFileA(
physical_drive.c_str(), 0,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0
@@ -582,7 +582,7 @@ Drive::get ()
DISK_GEOMETRY geom;
DWORD returned;
- BOOL r = DeviceIoControl (
+ BOOL r = DeviceIoControl(
device, IOCTL_DISK_GET_DRIVE_GEOMETRY, 0, 0,
&geom, sizeof(geom), &returned, 0
);
@@ -597,11 +597,11 @@ Drive::get ()
if (r) {
uint64_t const disk_size = geom.Cylinders.QuadPart * geom.TracksPerCylinder * geom.SectorsPerTrack * geom.BytesPerSector;
- drives.push_back (Drive(physical_drive, locked ? vector<boost::filesystem::path>() : mount_points[*device_number], disk_size, friendly_name, optional<string>()));
+ drives.push_back(Drive(physical_drive, locked ? vector<boost::filesystem::path>() : mount_points[*device_number], disk_size, friendly_name, optional<string>()));
LOG_DISK("Added drive %1%2", drives.back().log_summary(), locked ? "(locked by us)" : "");
}
- CloseHandle (device);
+ CloseHandle(device);
}
return drives;
@@ -609,37 +609,37 @@ Drive::get ()
bool
-Drive::unmount ()
+Drive::unmount()
{
LOG_DISK("Unmounting %1 with %2 mount points", _device, _mount_points.size());
- DCPOMATIC_ASSERT (_mount_points.size() == 1);
- string const device_name = String::compose ("\\\\.\\%1", _mount_points.front());
- string const truncated = device_name.substr (0, device_name.length() - 1);
+ DCPOMATIC_ASSERT(_mount_points.size() == 1);
+ string const device_name = String::compose("\\\\.\\%1", _mount_points.front());
+ string const truncated = device_name.substr(0, device_name.length() - 1);
LOG_DISK("Actually opening %1", truncated);
- HANDLE device = CreateFileA (truncated.c_str(), (GENERIC_READ | GENERIC_WRITE), FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
+ HANDLE device = CreateFileA(truncated.c_str(), (GENERIC_READ | GENERIC_WRITE), FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
if (device == INVALID_HANDLE_VALUE) {
LOG_DISK("Could not open %1 for unmount (%2)", truncated, GetLastError());
return false;
}
DWORD returned;
- BOOL r = DeviceIoControl (device, FSCTL_LOCK_VOLUME, 0, 0, 0, 0, &returned, 0);
+ BOOL r = DeviceIoControl(device, FSCTL_LOCK_VOLUME, 0, 0, 0, 0, &returned, 0);
if (!r) {
LOG_DISK("Unmount of %1 failed (%2)", truncated, GetLastError());
return false;
}
LOG_DISK("Unmount of %1 succeeded", _device);
- locked_volumes.push_back (make_pair(device, _device));
+ locked_volumes.push_back(make_pair(device, _device));
return true;
}
boost::filesystem::path
-config_path (optional<string> version)
+config_path(optional<string> version)
{
boost::filesystem::path p;
- p /= g_get_user_config_dir ();
+ p /= g_get_user_config_dir();
p /= "dcpomatic2";
if (version) {
p /= *version;
@@ -649,27 +649,27 @@ config_path (optional<string> version)
void
-disk_write_finished ()
+disk_write_finished()
{
for (auto const& i: locked_volumes) {
- CloseHandle (i.first);
+ CloseHandle(i.first);
}
}
string
-dcpomatic::get_process_id ()
+dcpomatic::get_process_id()
{
return fmt::to_string(GetCurrentProcessId());
}
bool
-show_in_file_manager (boost::filesystem::path, boost::filesystem::path select)
+show_in_file_manager(boost::filesystem::path, boost::filesystem::path select)
{
std::wstringstream args;
args << "/select," << select;
- auto const r = ShellExecute (0, L"open", L"explorer.exe", args.str().c_str(), 0, SW_SHOWDEFAULT);
+ auto const r = ShellExecute(0, L"open", L"explorer.exe", args.str().c_str(), 0, SW_SHOWDEFAULT);
return (reinterpret_cast<int64_t>(r) <= 32);
}