2 Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 /** @file src/lib/cross.h
22 * @brief Cross-platform compatibility code.
25 #ifndef DCPOMATIC_CROSS_H
26 #define DCPOMATIC_CROSS_H
29 #include <IOKit/pwr_mgt/IOPMLib.h>
31 #include <boost/filesystem.hpp>
32 #include <boost/thread/mutex.hpp>
33 #include <boost/optional.hpp>
35 #ifdef DCPOMATIC_WINDOWS
36 #define WEXITSTATUS(w) (w)
42 void dcpomatic_sleep_seconds (int);
43 void dcpomatic_sleep_milliseconds (int);
44 extern std::string cpu_info ();
45 extern void run_ffprobe (boost::filesystem::path, boost::filesystem::path);
46 extern std::list<std::pair<std::string, std::string> > mount_info ();
47 extern boost::filesystem::path openssl_path ();
49 extern boost::filesystem::path disk_writer_path ();
52 extern boost::filesystem::path app_contents ();
54 #ifdef DCPOMATIC_WINDOWS
55 extern void maybe_open_console ();
57 extern boost::filesystem::path shared_path ();
58 extern FILE * fopen_boost (boost::filesystem::path, std::string);
59 extern int dcpomatic_fseek (FILE *, int64_t, int);
60 extern void start_batch_converter (boost::filesystem::path dcpomatic);
61 extern void start_player (boost::filesystem::path dcpomatic);
62 extern uint64_t thread_id ();
63 extern int avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags);
64 extern boost::filesystem::path home_directory ();
65 extern std::string command_and_read (std::string cmd);
66 extern bool running_32_on_64 ();
67 extern void unprivileged ();
68 extern boost::filesystem::path config_path ();
70 class PrivilegeEscalator
73 PrivilegeEscalator ();
74 ~PrivilegeEscalator ();
78 * @brief A class which tries to keep the computer awake on various operating systems.
80 * Create a Waker to prevent sleep, and call nudge() every so often (every minute or so).
81 * Destroy the Waker to allow sleep again.
94 IOPMAssertionID _assertion_id;
101 Drive (std::string internal_name, uint64_t size, bool mounted, boost::optional<std::string> vendor, boost::optional<std::string> model)
102 : _internal_name(internal_name)
109 std::string description () const;
110 std::string internal_name () const {
111 return _internal_name;
113 bool mounted () const {
118 std::string _internal_name;
122 boost::optional<std::string> _vendor;
123 boost::optional<std::string> _model;
126 std::vector<Drive> get_drives ();
127 /** Unmount any mounted partitions on a drive.
128 * @return true on success, false on failure.
130 bool unmount_drive (std::string drive);