diff --git a/Source/CLI/CLI.cpp b/Source/CLI/CLI.cpp index ae36ed99..01307e34 100644 --- a/Source/CLI/CLI.cpp +++ b/Source/CLI/CLI.cpp @@ -123,7 +123,14 @@ void Log_0(struct MediaInfo_Event_Log_0* Event) // If no Implementation Schema registered, use one by default if (!MCL.get_implementation_schema_file().length()) - MCL.create_default_implementation_schema(); + { + if (MCL.create_default_implementation_schema(err) != 0) + { + if (err == "Unable to write implementation schema file.") + err += " Check write permissions on MediaConch data directory."; + return CLI_RETURN_ERROR; + } + } if (!MCL.ReportAndFormatCombination_IsValid(files, report_set, display_content, format, err)) diff --git a/Source/Common/Core.cpp b/Source/Common/Core.cpp index 01dc3274..a5cb3e60 100644 --- a/Source/Common/Core.cpp +++ b/Source/Common/Core.cpp @@ -224,7 +224,7 @@ const std::string& Core::get_implementation_schema_file() } //--------------------------------------------------------------------------- -void Core::create_default_implementation_schema() +int Core::create_default_implementation_schema(std::string& err) { std::string path = get_local_data_path(); std::string file = path + "MatroskaSchema.xml"; @@ -233,12 +233,17 @@ void Core::create_default_implementation_schema() ofs.open(file.c_str(), std::ofstream::out | std::ofstream::binary); if (!ofs.is_open()) - return; + { + err = "Unable to write implementation schema file."; + return -1; + } ofs << xsl_schema_matroska_schema; ofs.close(); set_implementation_schema_file(file); + + return 0; } //--------------------------------------------------------------------------- diff --git a/Source/Common/Core.h b/Source/Common/Core.h index 01509906..2358d78f 100644 --- a/Source/Common/Core.h +++ b/Source/Common/Core.h @@ -160,7 +160,7 @@ class Core const std::map& get_implementation_options() const; void set_implementation_schema_file(const std::string& file); const std::string& get_implementation_schema_file(); - void create_default_implementation_schema(); + int create_default_implementation_schema(std::string& err); void set_implementation_verbosity(const std::string& verbosity); const std::string& get_implementation_verbosity(); void set_compression_mode(MediaConchLib::compression compress); diff --git a/Source/Common/MediaConchLib.cpp b/Source/Common/MediaConchLib.cpp index 87c108f5..db1dff10 100644 --- a/Source/Common/MediaConchLib.cpp +++ b/Source/Common/MediaConchLib.cpp @@ -733,9 +733,9 @@ const std::string& MediaConchLib::get_implementation_schema_file() } //--------------------------------------------------------------------------- -void MediaConchLib::create_default_implementation_schema() +int MediaConchLib::create_default_implementation_schema(std::string& err) { - core->create_default_implementation_schema(); + return core->create_default_implementation_schema(err); } //--------------------------------------------------------------------------- diff --git a/Source/Common/MediaConchLib.h b/Source/Common/MediaConchLib.h index 6d9c516d..051b7784 100644 --- a/Source/Common/MediaConchLib.h +++ b/Source/Common/MediaConchLib.h @@ -369,7 +369,7 @@ class MediaConchLib // Implementation checker arguments void set_implementation_schema_file(const std::string& file); const std::string& get_implementation_schema_file(); - void create_default_implementation_schema(); + int create_default_implementation_schema(std::string& err); void set_implementation_verbosity(const std::string& verbosity); const std::string& get_implementation_verbosity(); diff --git a/Source/Daemon/Daemon.cpp b/Source/Daemon/Daemon.cpp index 26cbcae7..d24b415d 100644 --- a/Source/Daemon/Daemon.cpp +++ b/Source/Daemon/Daemon.cpp @@ -73,7 +73,13 @@ namespace MediaConch // If no Implementation Schema registered, use one by default if (!MCL->get_implementation_schema_file().length()) - MCL->create_default_implementation_schema(); + { + if (MCL->create_default_implementation_schema(err) != 0) + { + std::clog << err << std::endl; + return -1; + } + } // Load policy MCL->load_system_policy(); diff --git a/Source/GUI/Qt/mainwindow.cpp b/Source/GUI/Qt/mainwindow.cpp index e5f23ca0..888b4a9d 100644 --- a/Source/GUI/Qt/mainwindow.cpp +++ b/Source/GUI/Qt/mainwindow.cpp @@ -89,7 +89,20 @@ MainWindow::MainWindow(QWidget *parent) : // Core configuration if (!MCL.get_implementation_schema_file().length()) - MCL.create_default_implementation_schema(); + { + if (MCL.create_default_implementation_schema(err) != 0) + { + if (err == "Unable to write implementation schema file.") + err += "\nCheck write permissions on MediaConch data directory."; + + QMessageBox msgBox(QMessageBox::Critical, tr("Initialisation error"), + QString().fromStdString(err), QMessageBox::Abort, parent); + + msgBox.exec(); + close(); + } + } + int nb_threads=QThread::idealThreadCount(); if (nb_threads!=-1) MCL.set_default_scheduler_max_threads(nb_threads);