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 extern void dcpomatic_sleep_seconds (int);
43 extern 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 ();
48 extern void make_foreground_application ();
50 extern boost::filesystem::path disk_writer_path ();
52 #ifdef DCPOMATIC_WINDOWS
53 extern void maybe_open_console ();
55 extern boost::filesystem::path resources_path ();
56 extern boost::filesystem::path xsd_path ();
57 extern boost::filesystem::path tags_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 ();
61 extern void start_player ();
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 bool running_32_on_64 ();
66 extern void unprivileged ();
67 extern boost::filesystem::path config_path ();
68 extern boost::filesystem::path directory_containing_executable ();
69 extern boost::filesystem::path fix_long_path (boost::filesystem::path path);
71 std::string get_process_id ();
74 class PrivilegeEscalator
77 PrivilegeEscalator ();
78 ~PrivilegeEscalator ();
84 * @brief A class which tries to keep the computer awake on various operating systems.
86 * Create a Waker to prevent sleep, and call nudge() every so often (every minute or so).
87 * Destroy the Waker to allow sleep again.
100 IOPMAssertionID _assertion_id;
107 Drive (std::string device, std::vector<boost::filesystem::path> mount_points, uint64_t size, boost::optional<std::string> vendor, boost::optional<std::string> model)
109 , _mount_points(mount_points)
115 explicit Drive (std::string);
117 std::string as_xml () const;
119 std::string description () const;
121 std::string device () const {
125 bool mounted () const {
126 return !_mount_points.empty();
129 std::string log_summary () const;
131 /** Unmount any mounted partitions on a drive.
132 * @return true on success, false on failure.
136 static std::vector<Drive> get ();
140 std::vector<boost::filesystem::path> _mount_points;
143 boost::optional<std::string> _vendor;
144 boost::optional<std::string> _model;
147 void disk_write_finished ();