/*
- Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "cross.h"
-#include "compose.hpp"
#include "log.h"
#include "dcpomatic_log.h"
#include "config.h"
#include "exceptions.h"
#include "warnings.h"
+#include <dcp/compose.h>
#include <dcp/raw_convert.h>
#include <glib.h>
extern "C" {
#include "i18n.h"
+
using std::pair;
using std::list;
using std::ifstream;
using std::map;
using std::shared_ptr;
using boost::optional;
-using boost::function;
+using std::function;
+
/** @param s Number of seconds to sleep for */
void
sleep (s);
}
+
void
dcpomatic_sleep_milliseconds (int ms)
{
usleep (ms * 1000);
}
+
/** @return A string of CPU information (model name etc.) */
string
cpu_info ()
char buffer[64];
size_t N = sizeof (buffer);
- if (sysctlbyname ("machdep.cpu.brand_string", buffer, &N, 0, 0) == 0) {
+ if (sysctlbyname("machdep.cpu.brand_string", buffer, &N, 0, 0) == 0) {
info = buffer;
}
boost::filesystem::path
directory_containing_executable ()
{
-#if BOOST_VERSION >= 106100
return boost::dll::program_location().parent_path();
-#else
- uint32_t size = 1024;
- char buffer[size];
- if (_NSGetExecutablePath (buffer, &size)) {
- throw runtime_error ("_NSGetExecutablePath failed");
- }
-
- boost::filesystem::path path (buffer);
- path = boost::filesystem::canonical (path);
- return path.parent_path ();
-#endif
}
void
run_ffprobe (boost::filesystem::path content, boost::filesystem::path out)
{
- boost::filesystem::path path = directory_containing_executable () / "ffprobe";
+ auto path = directory_containing_executable () / "ffprobe";
string ffprobe = "\"" + path.string() + "\" \"" + content.string() + "\" 2> \"" + out.string() + "\"";
LOG_GENERAL (N_("Probing with %1"), ffprobe);
}
-list<pair<string, string> >
+
+list<pair<string, string>>
mount_info ()
{
- list<pair<string, string> > m;
- return m;
+ return {};
}
+
boost::filesystem::path
openssl_path ()
{
}
#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.
FILE *
fopen_boost (boost::filesystem::path p, string t)
{
- return fopen (p.c_str(), t.c_str ());
+ return fopen (p.c_str(), t.c_str());
}
+
int
dcpomatic_fseek (FILE* stream, int64_t offset, int whence)
{
return fseek (stream, offset, whence);
}
+
void
Waker::nudge ()
{
}
+
Waker::Waker ()
{
boost::mutex::scoped_lock lm (_mutex);
IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id);
}
+
Waker::~Waker ()
{
boost::mutex::scoped_lock lm (_mutex);
IOPMAssertionRelease (_assertion_id);
}
+
void
start_tool (string executable, string app)
{
- boost::filesystem::path exe_path = directory_containing_executable();
- exe_path = exe_path.parent_path (); // Contents
- exe_path = exe_path.parent_path (); // DCP-o-matic 2.app
- exe_path = exe_path.parent_path (); // Applications
+ auto exe_path = directory_containing_executable();
+ exe_path = exe_path.parent_path(); // Contents
+ exe_path = exe_path.parent_path(); // DCP-o-matic 2.app
+ exe_path = exe_path.parent_path(); // Applications
exe_path /= app;
exe_path /= "Contents";
exe_path /= "MacOS";
return (uint64_t) pthread_self ();
}
+
int
avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags)
{
return avio_open (s, file.c_str(), flags);
}
+
boost::filesystem::path
home_directory ()
{
- return getenv("HOME");
+ return getenv("HOME");
}
+
/** @return true if this process is a 32-bit one running on a 64-bit-capable OS */
bool
running_32_on_64 ()
return false;
}
+
static optional<string>
get_vendor (CFDictionaryRef& description)
{
return s;
}
+
static optional<string>
get_model (CFDictionaryRef& description)
{
return s;
}
+
struct MediaPath
{
bool real; ///< true for a "real" disk, false for a synthesized APFS one
std::string prt; ///< "PRT" entry from the media path
};
+
static optional<MediaPath>
analyse_media_path (CFDictionaryRef& description)
{
return mp;
}
+
static bool
is_whole_drive (DADiskRef& disk)
{
return whole_media;
}
+
static optional<boost::filesystem::path>
mount_point (CFDictionaryRef& description)
{
return boost::filesystem::path(mount_path_buffer);
}
+
/* Here follows some rather intricate and (probably) fragile code to find the list of available
* "real" drives on macOS that we might want to write a DCP to.
*
unsigned long size;
};
+
static void
disk_appeared (DADiskRef disk, void* context)
{
reinterpret_cast<vector<Disk>*>(context)->push_back(this_disk);
}
+
vector<Drive>
Drive::get ()
{
using namespace boost::algorithm;
vector<Disk> disks;
- DASessionRef session = DASessionCreate(kCFAllocatorDefault);
+ auto session = DASessionCreate(kCFAllocatorDefault);
if (!session) {
return {};
}
DARegisterDiskAppearedCallback (session, NULL, disk_appeared, &disks);
- CFRunLoopRef run_loop = CFRunLoopGetCurrent ();
+ auto run_loop = CFRunLoopGetCurrent ();
DASessionScheduleWithRunLoop (session, run_loop, kCFRunLoopDefaultMode);
CFRunLoopStop (run_loop);
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.05, 0);
}
/* Make a map of the PRT codes and mount points of mounted, synthesized disks */
- map<string, vector<boost::filesystem::path> > mounted_synths;
+ map<string, vector<boost::filesystem::path>> mounted_synths;
for (auto& i: disks) {
if (!i.real && !i.mount_points.empty()) {
LOG_DISK("Found a mounted synth %1 with %2", i.mount_point, i.prt);
{
LOG_DISK_NC("Unmount operation started");
- DASessionRef session = DASessionCreate(kCFAllocatorDefault);
+ auto session = DASessionCreate(kCFAllocatorDefault);
if (!session) {
return false;
}
- DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, session, _device.c_str());
+ auto disk = DADiskCreateFromBSDName(kCFAllocatorDefault, session, _device.c_str());
if (!disk) {
return false;
}
{
return dcp::raw_convert<string>(getpid());
}
+
+
+boost::filesystem::path
+fix_long_path (boost::filesystem::path path)
+{
+ return path;
+}