OSDN Git Service

Build fix for latest changes in MUtilities library.
[x264-launcher/x264-launcher.git] / src / source_abstract.cpp
index 5803169..f623969 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Simple x264 Launcher
-// Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
 
 //MUtils
 #include <MUtils/Global.h>
+#include <MUtils/OSSupport.h>
 #include <MUtils/Exception.h>
 
 //Qt
@@ -67,7 +68,7 @@ bool AbstractSource::checkSourceProperties(ClipInfo &clipInfo)
        checkSourceProperties_init(patterns, cmdLine);
 
        log("Creating process:");
-       if(!startProcess(process, getBinaryPath(), cmdLine, true, &getExtraPaths()))
+       if(!startProcess(process, getBinaryPath(), cmdLine, true, &getExtraPaths(), &getExtraEnv()))
        {
                return false;;
        }
@@ -191,7 +192,7 @@ bool AbstractSource::createProcess(QProcess &processEncode, QProcess&processInpu
        buildCommandLine(cmdLine_Input);
 
        log("Creating input process:");
-       if(!startProcess(processInput, getBinaryPath(), cmdLine_Input, false, &getExtraPaths()))
+       if(!startProcess(processInput, getBinaryPath(), cmdLine_Input, false, &getExtraPaths(), &getExtraEnv()))
        {
                return false;
        }
@@ -207,3 +208,26 @@ const AbstractSourceInfo& AbstractSource::getSourceInfo(void)
 {
        MUTILS_THROW("[getSourceInfo] This function must be overwritten in sub-classes!");
 }
+
+// ------------------------------------------------------------
+// Auxiliary FUnctions
+// ------------------------------------------------------------
+
+QHash<QString, QString> AbstractSource::getExtraEnv(void) const
+{
+       QHash<QString, QString> extraEnv;
+
+       const QString profilePath = MUtils::OS::known_folder(MUtils::OS::FOLDER_PROFILE_USER);
+       if (!profilePath.isEmpty())
+       {
+               extraEnv.insert("USERPROFILE", QDir::toNativeSeparators(profilePath));
+       }
+
+       const QString appDataPath = MUtils::OS::known_folder(MUtils::OS::FOLDER_APPDATA_ROAM);
+       if (!appDataPath.isEmpty())
+       {
+               extraEnv.insert("APPDATA", QDir::toNativeSeparators(appDataPath));
+       }
+
+       return extraEnv;
+}
\ No newline at end of file