diff --git a/Rakefile b/Rakefile index 48484af8f..d652c414e 100755 --- a/Rakefile +++ b/Rakefile @@ -687,7 +687,7 @@ end { :name => 'rmff', :dir => 'lib/librmff' }, { :name => 'pugixml', :dir => 'lib/pugixml/src' }, { :name => 'mpegparser', :dir => 'src/mpegparser' }, - { :name => 'mtxcommon', :dir => [ 'src/common' ] + %w{chapters checksums compression strings tags xml}.collect { |e| "src/common/#{e}" } }, + { :name => 'mtxcommon', :dir => [ 'src/common' ] + FileList['src/common/*'].select { |e| FileTest.directory? e } }, { :name => 'mtxinput', :dir => 'src/input' }, { :name => 'mtxoutput', :dir => 'src/output' }, { :name => 'mtxmerge', :dir => 'src/merge', :except => [ 'mkvmerge.cpp' ], }, diff --git a/src/common/common.cpp b/src/common/common.cpp index 05f0488f5..432cd5edd 100644 --- a/src/common/common.cpp +++ b/src/common/common.cpp @@ -135,7 +135,7 @@ set_process_priority(int priority) { // If the lowest priority should be used and we're on Vista or later // then use background priority. This also selects a lower I/O // priority. - if ((-2 == priority) && (get_windows_version() >= WINDOWS_VERSION_VISTA)) { + if ((-2 == priority) && (mtx::sys::get_windows_version() >= WINDOWS_VERSION_VISTA)) { SetPriorityClass(GetCurrentProcess(), PROCESS_MODE_BACKGROUND_BEGIN); SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN); return; @@ -189,7 +189,7 @@ mtx_common_init(std::string const &program_name, stereo_mode_c::init(); - mtx::determine_path_to_current_executable(argv0 ? std::string{argv0} : std::string{}); + mtx::sys::determine_path_to_current_executable(argv0 ? std::string{argv0} : std::string{}); } std::string const & diff --git a/src/common/extern_data.cpp b/src/common/extern_data.cpp index 8085a91e2..9c4cfce5a 100644 --- a/src/common/extern_data.cpp +++ b/src/common/extern_data.cpp @@ -2670,7 +2670,7 @@ guess_mime_type_internal(std::string ext, # endif // MAGIC_MIME_TYPE # ifdef SYS_WINDOWS - auto magic_filename = (mtx::get_installation_path() / "data" / "magic").string(); + auto magic_filename = (mtx::sys::get_installation_path() / "data" / "magic").string(); if (!m || (-1 == magic_load(m, magic_filename.c_str()))) return guess_mime_type_by_ext(ext); # else // defined(SYS_WINDOWS) diff --git a/src/common/fs_sys_helpers.h b/src/common/fs_sys_helpers.h index 47fe2d797..ac72469a6 100644 --- a/src/common/fs_sys_helpers.h +++ b/src/common/fs_sys_helpers.h @@ -15,14 +15,22 @@ #include "common/common_pch.h" +namespace mtx { namespace sys { + int64_t get_current_time_millis(); +int system(std::string const &command); + +void determine_path_to_current_executable(std::string const &argv0); +bfs::path get_current_exe_path(std::string const &argv0); +bfs::path get_application_data_folder(); +bfs::path get_installation_path(); + std::string get_environment_variable(const std::string &key); #if defined(SYS_WINDOWS) bool get_registry_key_value(const std::string &key, const std::string &value_name, std::string &value); - void set_environment_variable(const std::string &key, const std::string &value); #define WINDOWS_VERSION_UNKNOWN 0x00000000 @@ -38,13 +46,6 @@ unsigned int get_windows_version(); #endif -namespace mtx { - -int system(std::string const &command); -void determine_path_to_current_executable(std::string const &argv0); -bfs::path get_application_data_folder(); -bfs::path get_installation_path(); - -} +}} #endif diff --git a/src/common/fs_sys_helpers/common.cpp b/src/common/fs_sys_helpers/common.cpp new file mode 100644 index 000000000..fa3f12249 --- /dev/null +++ b/src/common/fs_sys_helpers/common.cpp @@ -0,0 +1,32 @@ +/* + mkvmerge -- utility for splicing together matroska files + from component media subtypes + + Distributed under the GPL v2 + see the file COPYING for details + or visit http://www.gnu.org/copyleft/gpl.html + + OS dependant file system & system helper functions + + Written by Moritz Bunkus +*/ + +#include "common/common_pch.h" + +#include "common/fs_sys_helpers.h" + +namespace mtx { namespace sys { + +static bfs::path s_current_executable_path; + +bfs::path +get_installation_path() { + return s_current_executable_path; +} + +void +determine_path_to_current_executable(std::string const &argv0) { + s_current_executable_path = get_current_exe_path(argv0); +} + +}} diff --git a/src/common/fs_sys_helpers/unix.cpp b/src/common/fs_sys_helpers/unix.cpp new file mode 100644 index 000000000..c67a57106 --- /dev/null +++ b/src/common/fs_sys_helpers/unix.cpp @@ -0,0 +1,113 @@ +/* + mkvmerge -- utility for splicing together matroska files + from component media subtypes + + Distributed under the GPL v2 + see the file COPYING for details + or visit http://www.gnu.org/copyleft/gpl.html + + OS dependant file system & system helper functions + + Written by Moritz Bunkus +*/ + +#include "common/common_pch.h" + +#if !defined(SYS_WINDOWS) + +#include +#include + +#if defined(SYS_APPLE) +# include +#endif + +#include "common/error.h" +#include "common/fs_sys_helpers.h" +#include "common/strings/editing.h" +#include "common/strings/utf8.h" + +namespace mtx { namespace sys { + +int64_t +get_current_time_millis() { + struct timeval tv; + if (0 != gettimeofday(&tv, nullptr)) + return -1; + + return (int64_t)tv.tv_sec * 1000 + (int64_t)tv.tv_usec / 1000; +} + +bfs::path +get_application_data_folder() { + auto home = getenv("HOME"); + if (!home) + return bfs::path{}; + + // If $HOME/.mkvtoolnix exists already then keep using it to avoid + // losing existing user configuration. + auto old_default_folder = bfs::path{home} / ".mkvtoolnix"; + if (boost::filesystem::exists(old_default_folder)) + return old_default_folder; + + // If XDG_CONFIG_HOME is set then use that folder. + auto xdg_config_home = getenv("XDG_CONFIG_HOME"); + if (xdg_config_home) + return bfs::path{xdg_config_home} / "mkvtoolnix"; + + // If all fails then use the XDG fallback folder for config files. + return bfs::path{home} / ".config" / "mkvtoolnix"; +} + +std::string +get_environment_variable(std::string const &key) { + auto var = getenv(key.c_str()); + return var ? var : ""; +} + +int +system(std::string const &command) { + return ::system(command.c_str()); +} + +bfs::path +get_current_exe_path(std::string const &argv0) { +#if defined(SYS_APPLE) + std::string file_name; + file_name.resize(4000); + + while (true) { + memset(&file_name[0], 0, file_name.size()); + uint32_t size = file_name.size(); + auto result = _NSGetExecutablePath(&file_name[0], &size); + file_name.resize(size); + + if (0 == result) + break; + } + + return bfs::absolute(bfs::path{file_name}).parent_path(); + +#else // SYS_APPLE + auto exe = bfs::path{"/proc/self/exe"}; + if (bfs::exists(exe)) { + auto exe_path = bfs::read_symlink(exe); + + // only make absolute if needed, to avoid crash in case the current dir is deleted (as bfs::absolute calls bfs::current_path here) + return (exe_path.is_absolute() ? exe_path : bfs::absolute(exe_path)).parent_path(); + } + + if (argv0.empty()) + return bfs::current_path(); + + exe = bfs::absolute(argv0); + if (bfs::exists(exe)) + return exe.parent_path(); + + return bfs::current_path(); +#endif +} + +}} + +#endif // !SYS_WINDOWS diff --git a/src/common/fs_sys_helpers.cpp b/src/common/fs_sys_helpers/windows.cpp similarity index 59% rename from src/common/fs_sys_helpers.cpp rename to src/common/fs_sys_helpers/windows.cpp index 9c1a87a7b..9b06ee641 100644 --- a/src/common/fs_sys_helpers.cpp +++ b/src/common/fs_sys_helpers/windows.cpp @@ -13,50 +13,21 @@ #include "common/common_pch.h" +#if defined(SYS_WINDOWS) + +#include +#include +#include +#include +#include +#include + #include "common/error.h" #include "common/fs_sys_helpers.h" #include "common/strings/editing.h" #include "common/strings/utf8.h" -#if defined(SYS_APPLE) -# include -#endif - -#if defined(SYS_WINDOWS) - -# include -# include -# include -# include -# include -# include - -#else - -# include -# include - -#endif - -static bfs::path s_current_executable_path; - -#if defined(SYS_WINDOWS) - -HANDLE -CreateFileUtf8(LPCSTR lpFileName, - DWORD dwDesiredAccess, - DWORD dwShareMode, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, - DWORD dwCreationDisposition, - DWORD dwFlagsAndAttributes, - HANDLE hTemplateFile) { - // convert the name to wide chars - wchar_t *wbuffer = win32_utf8_to_utf16(lpFileName); - HANDLE ret = CreateFileW(wbuffer, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); - delete []wbuffer; - - return ret; -} +namespace mtx { namespace sys { int64_t get_current_time_millis() { @@ -138,7 +109,7 @@ get_windows_version() { } bfs::path -mtx::get_application_data_folder() { +get_application_data_folder() { wchar_t szPath[MAX_PATH]; if (SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_APPDATA | CSIDL_FLAG_CREATE, nullptr, 0, szPath))) @@ -147,51 +118,8 @@ mtx::get_application_data_folder() { return bfs::path{}; } -#else // SYS_WINDOWS - -int64_t -get_current_time_millis() { - struct timeval tv; - if (0 != gettimeofday(&tv, nullptr)) - return -1; - - return (int64_t)tv.tv_sec * 1000 + (int64_t)tv.tv_usec / 1000; -} - -bfs::path -mtx::get_application_data_folder() { - const char *home = getenv("HOME"); - if (!home) - return bfs::path{}; - - // If $HOME/.mkvtoolnix exists already then keep using it to avoid - // losing existing user configuration. - auto old_default_folder = bfs::path{home} / ".mkvtoolnix"; - if (boost::filesystem::exists(old_default_folder)) - return old_default_folder; - - // If XDG_CONFIG_HOME is set then use that folder. - auto xdg_config_home = getenv("XDG_CONFIG_HOME"); - if (xdg_config_home) - return bfs::path{xdg_config_home} / "mkvtoolnix"; - - // If all fails then use the XDG fallback folder for config files. - return bfs::path{home} / ".config" / "mkvtoolnix"; -} - -std::string -get_environment_variable(std::string const &key) { - auto var = getenv(key.c_str()); - return var ? var : ""; -} - -#endif // SYS_WINDOWS - -namespace mtx { - int system(std::string const &command) { -#ifdef SYS_WINDOWS std::wstring wcommand = to_wide(command); auto mem = memory_c::clone(wcommand.c_str(), (wcommand.length() + 1) * sizeof(wchar_t)); @@ -221,13 +149,9 @@ system(std::string const &command) { return !result ? -1 : 0; -#else // SYS_WINDOWS - return ::system(command.c_str()); -#endif // SYS_WINDOWS } -#if defined(SYS_WINDOWS) -static bfs::path +bfs::path get_current_exe_path(std::string const &) { std::wstring file_name; file_name.resize(4000); @@ -246,59 +170,6 @@ get_current_exe_path(std::string const &) { return bfs::absolute(bfs::path{to_utf8(file_name)}).parent_path(); } -#elif defined(SYS_APPLE) +}} -static bfs::path -get_current_exe_path(std::string const &) { - std::string file_name; - file_name.resize(4000); - - while (true) { - memset(&file_name[0], 0, file_name.size()); - uint32_t size = file_name.size(); - auto result = _NSGetExecutablePath(&file_name[0], &size); - file_name.resize(size); - - if (0 == result) - break; - } - - return bfs::absolute(bfs::path{file_name}).parent_path(); -} - -#else // Neither Windows nor Mac OS - -static bfs::path -get_current_exe_path(std::string const &argv0) { - // Linux - auto exe = bfs::path{"/proc/self/exe"}; - if (bfs::exists(exe)) { - auto exe_path = bfs::read_symlink(exe); - - // only make absolute if needed, to avoid crash in case the current dir is deleted (as bfs::absolute calls bfs::current_path here) - return (exe_path.is_absolute() ? exe_path : bfs::absolute(exe_path)).parent_path(); - } - - if (argv0.empty()) - return bfs::current_path(); - - exe = bfs::absolute(argv0); - if (bfs::exists(exe)) - return exe.parent_path(); - - return bfs::current_path(); -} - -#endif - -bfs::path -get_installation_path() { - return s_current_executable_path; -} - -void -determine_path_to_current_executable(std::string const &argv0) { - s_current_executable_path = get_current_exe_path(argv0); -} - -} +#endif // SYS_WINDOWS diff --git a/src/common/kax_file.cpp b/src/common/kax_file.cpp index 9f9fa95b1..5b70ef11f 100644 --- a/src/common/kax_file.cpp +++ b/src/common/kax_file.cpp @@ -196,7 +196,7 @@ kax_file_c::resync_to_level1_element_internal(uint32_t wanted_id) { m_resync_start_pos = m_in->getFilePointer(); uint32_t actual_id = m_in->read_uint32_be(); - int64_t start_time = get_current_time_millis(); + int64_t start_time = mtx::sys::get_current_time_millis(); bool is_cluster_id = !wanted_id || (EBML_ID_VALUE(EBML_ID(KaxCluster)) == wanted_id); // 0 means: any level 1 element will do mxinfo(boost::format(Y("%1%: Error in the Matroska file structure at position %2%. Resyncing to the next level 1 element.\n")) @@ -211,7 +211,7 @@ kax_file_c::resync_to_level1_element_internal(uint32_t wanted_id) { mxinfo(boost::format("kax_file::resync_to_level1_element(): starting at %1% potential ID %|2$08x|\n") % m_resync_start_pos % actual_id); while (m_in->getFilePointer() < m_file_size) { - int64_t now = get_current_time_millis(); + int64_t now = mtx::sys::get_current_time_millis(); if ((now - start_time) >= 10000) { mxinfo(boost::format("Still resyncing at position %1%.\n") % m_in->getFilePointer()); start_time = now; diff --git a/src/common/locale.cpp b/src/common/locale.cpp index 28de7d1da..f0eecd747 100644 --- a/src/common/locale.cpp +++ b/src/common/locale.cpp @@ -317,7 +317,7 @@ get_local_charset() { std::string get_local_console_charset() { #if defined(SYS_WINDOWS) - if (get_windows_version() >= WINDOWS_VERSION_VISTA) + if (mtx::sys::get_windows_version() >= WINDOWS_VERSION_VISTA) return std::string("CP") + to_string(GetACP()); return std::string("CP") + to_string(GetOEMCP()); #else diff --git a/src/common/logger.cpp b/src/common/logger.cpp index b6fb1aebe..e982bccd0 100644 --- a/src/common/logger.cpp +++ b/src/common/logger.cpp @@ -24,7 +24,7 @@ static auto s_program_start_time = std::chrono::system_clock::now(); logger_c::logger_c(bfs::path const &file_name) : m_file_name(file_name) - , m_log_start(get_current_time_millis()) + , m_log_start(mtx::sys::get_current_time_millis()) { if (!m_file_name.is_absolute()) m_file_name = bfs::temp_directory_path() / m_file_name; diff --git a/src/common/mm_io_win.cpp b/src/common/mm_io_win.cpp index 707335cb6..6cd9bdc6b 100644 --- a/src/common/mm_io_win.cpp +++ b/src/common/mm_io_win.cpp @@ -34,14 +34,21 @@ #include "common/strings/parsing.h" #include "common/strings/utf8.h" -HANDLE -CreateFileUtf8(LPCSTR lpFileName, - DWORD dwDesiredAccess, - DWORD dwShareMode, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, - DWORD dwCreationDisposition, - DWORD dwFlagsAndAttributes, - HANDLE hTemplateFile); +static HANDLE +create_file_utf8(LPCSTR lpFileName, + DWORD dwDesiredAccess, + DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile) { + // convert the name to wide chars + wchar_t *wbuffer = win32_utf8_to_utf16(lpFileName); + HANDLE ret = CreateFileW(wbuffer, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); + delete []wbuffer; + + return ret; +} mm_file_io_c::mm_file_io_c(const std::string &path, const open_mode mode) @@ -79,7 +86,7 @@ mm_file_io_c::mm_file_io_c(const std::string &path, if ((MODE_WRITE == mode) || (MODE_CREATE == mode)) prepare_path(path); - m_file = (void *)CreateFileUtf8(path.c_str(), access_mode, share_mode, nullptr, disposition, 0, nullptr); + m_file = (void *)create_file_utf8(path.c_str(), access_mode, share_mode, nullptr, disposition, 0, nullptr); if (static_cast(m_file) == INVALID_HANDLE_VALUE) throw mtx::mm_io::open_x{mtx::mm_io::make_error_code()}; diff --git a/src/common/translation.cpp b/src/common/translation.cpp index aa270a56f..c87494081 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -131,11 +131,11 @@ translation_c::get_default_ui_locale() { #if defined(HAVE_LIBINTL_H) # if defined(SYS_WINDOWS) - std::string env_var = get_environment_variable("LC_MESSAGES"); + std::string env_var = mtx::sys::get_environment_variable("LC_MESSAGES"); if (!env_var.empty() && (-1 != look_up_translation(env_var))) return env_var; - env_var = get_environment_variable("LANG"); + env_var = mtx::sys::get_environment_variable("LANG"); if (!env_var.empty() && (-1 != look_up_translation(env_var))) return env_var; @@ -250,7 +250,7 @@ init_locales(std::string locale) { } # if defined(SYS_WINDOWS) - set_environment_variable("LANGUAGE", ""); + mtx::sys::set_environment_variable("LANGUAGE", ""); if (!locale.empty()) { // The Windows system headers define LC_MESSAGES but @@ -261,8 +261,8 @@ init_locales(std::string locale) { // modified by SetEnvironmentVariable() and the C library's cache // of said environment which is modified via _putenv(). - set_environment_variable("LANG", locale); - set_environment_variable("LC_MESSAGES", locale); + mtx::sys::set_environment_variable("LANG", locale); + mtx::sys::set_environment_variable("LC_MESSAGES", locale); translation_c::set_active_translation(locale); } @@ -273,7 +273,7 @@ init_locales(std::string locale) { std::locale::global(utf8_locale); boost::filesystem::path::imbue(utf8_locale); - locale_dir = g_cc_local_utf8->native((mtx::get_installation_path() / "locale").string()); + locale_dir = g_cc_local_utf8->native((mtx::sys::get_installation_path() / "locale").string()); # else // SYS_WINDOWS std::string chosen_locale; diff --git a/src/merge/cues.cpp b/src/merge/cues.cpp index 6bc45660c..a81dcfc09 100644 --- a/src/merge/cues.cpp +++ b/src/merge/cues.cpp @@ -78,9 +78,9 @@ cues_c::write(mm_io_c &out, if (!m_points.size() || !g_cue_writing_requested) return; - // auto start = get_current_time_millis(); + // auto start = mtx::sys::get_current_time_millis(); sort(); - // auto end_sort = get_current_time_millis(); + // auto end_sort = mtx::sys::get_current_time_millis(); // Need to write the (empty) cues element so that its position will // be set for indexing in g_kax_sh_main. Necessary because there's @@ -126,7 +126,7 @@ cues_c::write(mm_io_c &out, m_codec_state_position_map.clear(); m_num_cue_points_postprocessed = 0; - // auto end_all = get_current_time_millis(); + // auto end_all = mtx::sys::get_current_time_millis(); // mxinfo(boost::format("dur sort %1% write %2% total %3%\n") % (end_sort - start) % (end_all - end_sort) % (end_all - start)); } diff --git a/src/merge/mkvmerge.cpp b/src/merge/mkvmerge.cpp index baddde39c..a781ae181 100644 --- a/src/merge/mkvmerge.cpp +++ b/src/merge/mkvmerge.cpp @@ -2511,7 +2511,7 @@ main(int argc, parse_args(args); - int64_t start = get_current_time_millis(); + int64_t start = mtx::sys::get_current_time_millis(); add_filelists_for_playlists(); create_readers(); @@ -2545,7 +2545,7 @@ main(int argc, % ex.what() % ex.error()); } - mxinfo(boost::format(Y("Muxing took %1%.\n")) % create_minutes_seconds_time_string((get_current_time_millis() - start + 500) / 1000, true)); + mxinfo(boost::format(Y("Muxing took %1%.\n")) % create_minutes_seconds_time_string((mtx::sys::get_current_time_millis() - start + 500) / 1000, true)); cleanup(); diff --git a/src/merge/output_control.cpp b/src/merge/output_control.cpp index 663570d42..f57fff824 100644 --- a/src/merge/output_control.cpp +++ b/src/merge/output_control.cpp @@ -304,7 +304,7 @@ display_progress(bool is_100percent = false) { bool display_progress = false; int current_percentage = (s_display_reader->get_progress() + s_display_files_done * 100) / s_display_path_length; - int64_t current_time = get_current_time_millis(); + int64_t current_time = mtx::sys::get_current_time_millis(); if ( (-1 == s_previous_percentage) || ((100 == current_percentage) && (100 > s_previous_percentage)) diff --git a/src/mkvtoolnix-gui/main_window/main_window.cpp b/src/mkvtoolnix-gui/main_window/main_window.cpp index e665cc3ef..5739d969e 100644 --- a/src/mkvtoolnix-gui/main_window/main_window.cpp +++ b/src/mkvtoolnix-gui/main_window/main_window.cpp @@ -246,7 +246,7 @@ MainWindow::checkForUpdates() { void MainWindow::silentlyCheckForUpdates() { - auto forceUpdateCheck = get_environment_variable("FORCE_UPDATE_CHECK") == "1"; + auto forceUpdateCheck = mtx::sys::get_environment_variable("FORCE_UPDATE_CHECK") == "1"; if (!forceUpdateCheck && !Util::Settings::get().m_checkForUpdates) return; @@ -275,7 +275,7 @@ MainWindow::updateCheckFinished(UpdateCheckStatus status, auto &settings = Util::Settings::get(); settings.m_lastUpdateCheck = QDateTime::currentDateTime(); - auto forceUpdateCheck = get_environment_variable("FORCE_UPDATE_CHECK") == "1"; + auto forceUpdateCheck = mtx::sys::get_environment_variable("FORCE_UPDATE_CHECK") == "1"; if (!forceUpdateCheck && !(release.current_version < release.latest_source)) return; diff --git a/src/mkvtoolnix-gui/mkvtoolnix_gui.cpp b/src/mkvtoolnix-gui/mkvtoolnix_gui.cpp index c19539a1b..ac5fbe44c 100644 --- a/src/mkvtoolnix-gui/mkvtoolnix_gui.cpp +++ b/src/mkvtoolnix-gui/mkvtoolnix_gui.cpp @@ -30,7 +30,7 @@ registerMetaTypes() { static void showPreviewWarning(QWidget *parent) { - if (get_environment_variable("NO_WARNING") == "1") + if (mtx::sys::get_environment_variable("NO_WARNING") == "1") return; auto dlg = std::make_unique(parent); diff --git a/src/mkvtoolnix-gui/util/settings.cpp b/src/mkvtoolnix-gui/util/settings.cpp index d94a37b6a..b8202b56e 100644 --- a/src/mkvtoolnix-gui/util/settings.cpp +++ b/src/mkvtoolnix-gui/util/settings.cpp @@ -112,7 +112,7 @@ Settings::exeWithPath(QString const &exe) { if (path.is_absolute()) return exe; - return to_qs((mtx::get_installation_path() / path).native()); + return to_qs((mtx::sys::get_installation_path() / path).native()); #else // defined(SYS_WINDOWS) return exe; #endif // defined(SYS_WINDOWS) diff --git a/src/mmg/helpers.cpp b/src/mmg/helpers.cpp index e6f341a1b..9c1784d36 100644 --- a/src/mmg/helpers.cpp +++ b/src/mmg/helpers.cpp @@ -277,7 +277,7 @@ format_tooltip(const wxString &s) { wxString get_temp_settings_file_name() { - return wxU((bfs::temp_directory_path() / (boost::format("mmg-mkvmerge-options-%1%-%2%") % wxGetProcessId() % get_current_time_millis()).str()).string()); + return wxU((bfs::temp_directory_path() / (boost::format("mmg-mkvmerge-options-%1%-%2%") % wxGetProcessId() % mtx::sys::get_current_time_millis()).str()).string()); } wxString diff --git a/src/mmg/jobs.cpp b/src/mmg/jobs.cpp index 605b969b1..3c558b75a 100644 --- a/src/mmg/jobs.cpp +++ b/src/mmg/jobs.cpp @@ -112,11 +112,11 @@ job_run_dialog::job_run_dialog(wxWindow *, m_geometry_saver.set_default_size(700, 700, true).restore(); #if defined(SYS_WINDOWS) - if (get_windows_version() >= WINDOWS_VERSION_7) + if (mtx::sys::get_windows_version() >= WINDOWS_VERSION_7) m_taskbar_progress = new taskbar_progress_c(this); #endif - m_start_time_total = get_current_time_millis(); + m_start_time_total = mtx::sys::get_current_time_millis(); m_next_remaining_time_update_total = m_start_time_total + 8000; start_next_job(); @@ -155,7 +155,7 @@ job_run_dialog::start_next_job() { return; } - m_start_time = get_current_time_millis(); + m_start_time = mtx::sys::get_current_time_millis(); m_next_remaining_time_update = m_start_time + 8000; st_remaining_time->SetLabel(Z("is being estimated")); @@ -251,7 +251,7 @@ job_run_dialog::process_input() { else if (wx_line.Find(wxT("#GUI#end_scanning_playlists")) == 0) { m_scanning_playlists = false; - m_start_time = get_current_time_millis(); + m_start_time = mtx::sys::get_current_time_millis(); m_next_remaining_time_update = m_start_time + 8000; if (!current_job) { @@ -300,7 +300,7 @@ job_run_dialog::update_remaining_time() { if (m_scanning_playlists || !m_progress) return; - int64_t now = get_current_time_millis(); + int64_t now = mtx::sys::get_current_time_millis(); if ((0 != (m_progress % 100)) && (now >= m_next_remaining_time_update)) { int64_t total_time = (now - m_start_time) * 100 / (m_progress % 100); diff --git a/src/mmg/mmg.cpp b/src/mmg/mmg.cpp index fa6e9e928..44ab68750 100644 --- a/src/mmg/mmg.cpp +++ b/src/mmg/mmg.cpp @@ -112,7 +112,7 @@ mmg_app::init_ui_locale() { m_ui_locale = locale; if (s_first_init) { - auto installation_path = mtx::get_installation_path(); + auto installation_path = mtx::sys::get_installation_path(); if (!installation_path.empty()) wxLocale::AddCatalogLookupPathPrefix(wxU((installation_path / "locale").string())); @@ -139,9 +139,9 @@ wxString mmg_app::get_config_file_name() const { #ifdef SYS_WINDOWS - return wxU((mtx::get_installation_path() / "mkvtoolnix.ini").string()); + return wxU((mtx::sys::get_installation_path() / "mkvtoolnix.ini").string()); #else - return wxU((mtx::get_application_data_folder() / "config").string()); + return wxU((mtx::sys::get_application_data_folder() / "config").string()); #endif } @@ -149,9 +149,9 @@ wxString mmg_app::get_jobs_folder() const { #if defined(SYS_WINDOWS) - return m_is_installed ? wxU(mtx::get_application_data_folder().string()) : wxU((mtx::get_installation_path() / "jobs").string()); + return m_is_installed ? wxU(mtx::sys::get_application_data_folder().string()) : wxU((mtx::sys::get_installation_path() / "jobs").string()); #else - return wxU((mtx::get_application_data_folder() / "jobs").string()); + return wxU((mtx::sys::get_application_data_folder() / "jobs").string()); #endif } diff --git a/src/mmg/mmg_dialog.cpp b/src/mmg/mmg_dialog.cpp index 43757b5bc..c6d4c643b 100644 --- a/src/mmg/mmg_dialog.cpp +++ b/src/mmg/mmg_dialog.cpp @@ -665,7 +665,7 @@ mmg_dialog::display_help(int id) { wxDirDialog dlg(this, Z("Choose the location of the mkvmerge GUI help files")); std::vector potential_help_paths; - wxString installation_path = wxU(mtx::get_installation_path().string()); + wxString installation_path = wxU(mtx::sys::get_installation_path().string()); if (!installation_path.IsEmpty()) potential_help_paths.push_back(installation_path + wxT("/doc")); diff --git a/src/mmg/mmg_options.cpp b/src/mmg/mmg_options.cpp index 75642b1f0..61bae4d12 100644 --- a/src/mmg/mmg_options.cpp +++ b/src/mmg/mmg_options.cpp @@ -81,7 +81,7 @@ mmg_options_t::mkvmerge_exe() { exe = bfs::path{}; if (exe.empty()) { - exe = mtx::get_installation_path(); + exe = mtx::sys::get_installation_path(); if (!exe.empty() && bfs::exists(exe) && bfs::exists(exe / exe_with_ext)) exe = exe / exe_with_ext; else @@ -91,7 +91,7 @@ mmg_options_t::mkvmerge_exe() { if (exe.empty()) exe = exe_with_ext; - wxLogMessage(wxT("mkvmerge_exe %s installation_path %s\n"), wxU(exe.string()).c_str(), wxU(mtx::get_installation_path().string()).c_str()); + wxLogMessage(wxT("mkvmerge_exe %s installation_path %s\n"), wxU(exe.string()).c_str(), wxU(mtx::sys::get_installation_path().string()).c_str()); return wxU(exe.string()); } diff --git a/src/mmg/mux_dialog.cpp b/src/mmg/mux_dialog.cpp index c2a41e6cc..dda691054 100644 --- a/src/mmg/mux_dialog.cpp +++ b/src/mmg/mux_dialog.cpp @@ -123,7 +123,7 @@ mux_dialog::run() { } #if defined(SYS_WINDOWS) - if (get_windows_version() >= WINDOWS_VERSION_7) { + if (mtx::sys::get_windows_version() >= WINDOWS_VERSION_7) { m_taskbar_progress = new taskbar_progress_c(mdlg); m_taskbar_progress->set_state(TBPF_NORMAL); m_taskbar_progress->set_value(0, 100); @@ -132,7 +132,7 @@ mux_dialog::run() { update_label(Z("Muxing in progress.")); - m_start_time = get_current_time_millis(); + m_start_time = mtx::sys::get_current_time_millis(); m_next_remaining_time_update = m_start_time + 8000; m_process = new mux_process{this}; @@ -187,7 +187,7 @@ mux_dialog::update_remaining_time() { if (m_scanning_playlists) return; - int64_t now = get_current_time_millis(); + int64_t now = mtx::sys::get_current_time_millis(); if ((0 == m_progress) || (now < m_next_remaining_time_update)) return; @@ -289,7 +289,7 @@ mux_dialog::on_output_available(wxCommandEvent &evt) { else if (line.Find(wxT("#GUI#end_scanning_playlists")) == 0) { m_scanning_playlists = false; - m_start_time = get_current_time_millis(); + m_start_time = mtx::sys::get_current_time_millis(); m_next_remaining_time_update = m_start_time + 8000; } else if (line.Find(Z("Progress")) == 0) { diff --git a/src/mmg/tabs/scan_directory_thread.cpp b/src/mmg/tabs/scan_directory_thread.cpp index 43ad2a3fe..5fb4d3656 100644 --- a/src/mmg/tabs/scan_directory_thread.cpp +++ b/src/mmg/tabs/scan_directory_thread.cpp @@ -89,7 +89,7 @@ scan_directory_thread_c::identify_file(wxString const &file_name) // log_it(boost::format("command: %1%\n") % to_utf8(command)); - int result = mtx::system(to_utf8(command)); + int result = mtx::sys::system(to_utf8(command)); try { mm_text_io_c in{new mm_file_io_c{to_utf8(opt_file_name + wxT("-out")), MODE_READ}}; diff --git a/src/mmg/tabs/scanning_for_playlists_dlg.cpp b/src/mmg/tabs/scanning_for_playlists_dlg.cpp index 35c7811b0..c05710a1f 100644 --- a/src/mmg/tabs/scanning_for_playlists_dlg.cpp +++ b/src/mmg/tabs/scanning_for_playlists_dlg.cpp @@ -45,7 +45,7 @@ scanning_for_playlists_dlg::scanning_for_playlists_dlg(wxWindow *parent, m_b_abort = new wxButton( this, wxID_CANCEL, Z("&Abort")); #if defined(SYS_WINDOWS) - if (get_windows_version() >= WINDOWS_VERSION_7) { + if (mtx::sys::get_windows_version() >= WINDOWS_VERSION_7) { m_taskbar_progress = new taskbar_progress_c(mdlg); m_taskbar_progress->set_state(TBPF_NORMAL); m_taskbar_progress->set_value(0, other_file_names.size()); @@ -91,7 +91,7 @@ scanning_for_playlists_dlg::~scanning_for_playlists_dlg() int scanning_for_playlists_dlg::scan() { - m_start_time = get_current_time_millis(); + m_start_time = mtx::sys::get_current_time_millis(); m_next_remaining_time_update = m_start_time + 8000; m_scanner->Create(); @@ -129,7 +129,7 @@ void scanning_for_playlists_dlg::on_progress_changed(wxCommandEvent &evt) { update_gauge(evt.GetInt()); - uint64_t now = get_current_time_millis(); + uint64_t now = mtx::sys::get_current_time_millis(); if ((0 == m_progress) || (now < m_next_remaining_time_update)) return;