mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-25 12:27:21 +00:00
Store job files in the application data folder.
Also moved mmg's config file from ~/.mkvmergeGUI to ~/.mkvtoolnix/config on non-Windows systems. Fix for bug 466.
This commit is contained in:
parent
0c36bf9953
commit
69a3a25345
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
2010-02-03 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* mmg: bug fix: The jobs will be saved in the 'mkvtoolnix/jobs'
|
||||
sub-directory of the 'application data' folder instead of the
|
||||
'jobs' folder in the current directory. On Windows this is the
|
||||
special 'application data' folder inside the user's profile
|
||||
directory, e.g. 'C:\Users\mbunkus\AppData\mkvtoolnix'. On
|
||||
non-Windows systems this is the folder '.mkvtoolnix' in the user's
|
||||
home directory.
|
||||
mmg's configuration file has also been moved from ~/.mkvmergeGUI
|
||||
to ~/.mkvtoolnix/config on non-Windows systems.
|
||||
Fix for bug 466.
|
||||
|
||||
2010-01-28 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* mkvextract: bug fix: Files are only opened for reading, not for
|
||||
|
@ -166,6 +166,18 @@ get_windows_version() {
|
||||
return (os_version_info.dwMajorVersion << 16) | os_version_info.dwMinorVersion;
|
||||
}
|
||||
|
||||
std::string
|
||||
get_application_data_folder() {
|
||||
wchar_t szPath[MAX_PATH];
|
||||
|
||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, szPath))) {
|
||||
PathAppend(szPath, TEXT("mkvtoolnix"));
|
||||
return to_utf8(std::wstring(szPath));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
#else // SYS_WINDOWS
|
||||
|
||||
# include <errno.h>
|
||||
@ -198,6 +210,15 @@ get_current_time_millis() {
|
||||
return (int64_t)tv.tv_sec * 1000 + (int64_t)tv.tv_usec / 1000;
|
||||
}
|
||||
|
||||
std::string
|
||||
get_application_data_folder() {
|
||||
const char *home = getenv("HOME");
|
||||
if (NULL == home)
|
||||
return "";
|
||||
|
||||
return std::string(home) + "/.mkvtoolnix";
|
||||
}
|
||||
|
||||
#endif // SYS_WINDOWS
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
@ -20,6 +20,7 @@
|
||||
int MTX_DLL_API fs_entry_exists(const char *path);
|
||||
void MTX_DLL_API create_directory(const char *path);
|
||||
int64_t MTX_DLL_API get_current_time_millis();
|
||||
std::string MTX_DLL_API get_application_data_folder();
|
||||
|
||||
#if defined(SYS_WINDOWS)
|
||||
|
||||
|
@ -144,7 +144,7 @@ job_run_dialog::start_next_job() {
|
||||
st_jobs->SetLabel(wxString::Format(Z("Processing job %d/%d"), current_job + 1, (int)jobs_to_start.size()));
|
||||
st_current->SetLabel(wxString::Format(Z("Current job ID %d:"), jobs[ndx].id));
|
||||
|
||||
mdlg->load(wxString::Format(wxT("%s/jobs/%d.mmg"), wxGetCwd().c_str(), jobs[ndx].id));
|
||||
mdlg->load(wxString::Format(wxT("%s/%d.mmg"), app->get_jobs_folder().c_str(), jobs[ndx].id));
|
||||
|
||||
opt_file_name.Printf(wxT("%smmg-mkvmerge-options-%d-%d"), get_temp_dir().c_str(), (int)wxGetProcessId(), (int)wxGetUTCTime());
|
||||
|
||||
@ -542,7 +542,7 @@ job_dialog::on_delete(wxCommandEvent &evt) {
|
||||
int k = 0;
|
||||
while (jobs.size() > i) {
|
||||
if (selected[k]) {
|
||||
wxRemoveFile(wxString::Format(wxT("jobs/%d.mmg"), jobs[i].id));
|
||||
wxRemoveFile(wxString::Format(wxT("%s/%d.mmg"), app->get_jobs_folder().c_str(), jobs[i].id));
|
||||
jobs.erase(jobs.begin() + i);
|
||||
lv_jobs->DeleteItem(i);
|
||||
} else
|
||||
@ -698,7 +698,7 @@ job_dialog::on_item_selected(wxListEvent &evt) {
|
||||
|
||||
void
|
||||
job_dialog::start_jobs(std::vector<int> &jobs_to_start) {
|
||||
wxString temp_settings = wxGetCwd() + wxT("/jobs/temp.mmg");
|
||||
wxString temp_settings = app->get_jobs_folder() + wxT("/temp.mmg");
|
||||
mdlg->save(temp_settings, true);
|
||||
|
||||
mdlg->Show(false);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "common/common.h"
|
||||
#include "common/extern_data.h"
|
||||
#include "common/extern_data.h"
|
||||
#include "common/fs_sys_helpers.h"
|
||||
#include "common/mm_io.h"
|
||||
#include "common/strings/formatting.h"
|
||||
#include "common/translation.h"
|
||||
@ -89,6 +90,37 @@ mmg_app::init_ui_locale() {
|
||||
init_locales(locale);
|
||||
}
|
||||
|
||||
wxString
|
||||
mmg_app::get_config_file_name() {
|
||||
return wxU(get_application_data_folder()) + wxT("/config");
|
||||
}
|
||||
|
||||
wxString
|
||||
mmg_app::get_jobs_folder() {
|
||||
return wxU(get_application_data_folder()) + wxT("/jobs");
|
||||
}
|
||||
|
||||
void
|
||||
mmg_app::prepare_mmg_data_folder() {
|
||||
// The 'jobs' folder is part of the application data
|
||||
// folder. Therefore both directories will be creatd.
|
||||
// 'prepare_path' treats the last part of the path as a file name;
|
||||
// therefore append a dummy file name so that all directory parts
|
||||
// will be created.
|
||||
mm_file_io_c::prepare_path(wxMB(get_jobs_folder() + wxT("/dummy")));
|
||||
|
||||
#if !defined(SYS_WINDOWS)
|
||||
// Migrate the config file from its old location ~/.mkvmergeGUI to
|
||||
// the new location ~/.mkvtoolnix/config
|
||||
wxString old_config_name;
|
||||
wxGetEnv(wxT("HOME"), &old_config_name);
|
||||
old_config_name += wxT("/.mkvmergeGUI");
|
||||
|
||||
if (wxFileExists(old_config_name))
|
||||
wxRenameFile(old_config_name, get_config_file_name());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
mmg_app::OnInit() {
|
||||
mtx_common_init();
|
||||
@ -98,7 +130,13 @@ mmg_app::OnInit() {
|
||||
wxString k, v;
|
||||
int index;
|
||||
|
||||
prepare_mmg_data_folder();
|
||||
|
||||
#if defined(SYS_WINDOWS)
|
||||
cfg = new wxConfig(wxT("mkvmergeGUI"));
|
||||
#else
|
||||
cfg = new wxFileConfig(wxT("mkvmergeGUI"), wxEmptyString, get_config_file_name());
|
||||
#endif
|
||||
wxConfigBase::Set(cfg);
|
||||
|
||||
init_ui_locale();
|
||||
|
@ -276,6 +276,9 @@ public:
|
||||
virtual int OnExit();
|
||||
virtual void init_ui_locale();
|
||||
virtual void handle_command_line_arguments();
|
||||
virtual wxString get_config_file_name();
|
||||
virtual wxString get_jobs_folder();
|
||||
virtual void prepare_mmg_data_folder();
|
||||
};
|
||||
|
||||
extern mmg_app *app;
|
||||
|
@ -1386,8 +1386,7 @@ mmg_dialog::on_add_to_jobqueue(wxCommandEvent &evt) {
|
||||
job.log = new wxString();
|
||||
jobs.push_back(job);
|
||||
|
||||
description.Printf(wxT("/jobs/%d.mmg"), job.id);
|
||||
save(wxGetCwd() + description);
|
||||
save(wxString::Format(wxT("%s/%d.mmg"), app->get_jobs_folder().c_str(), job.id));
|
||||
|
||||
save_job_queue();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user