Browse Source

Fix SDLCore executeExternalCommand

Per Bodin 13 năm trước cách đây
mục cha
commit
bcd8c13916

+ 1 - 1
Core/Contents/Include/PolySDLCore.h

@@ -68,7 +68,7 @@ namespace Polycode {
 		std::vector<String> openFilePicker(std::vector<CoreFileExtension> extensions, bool allowMultiple);
 		void resizeTo(int xRes, int yRes);
 
-		String executeExternalCommand(String command, String inDirectory="");
+		String executeExternalCommand(String command, String args, String inDirectory="");
 		void openURL(String url);
 
 	private:

+ 8 - 2
Core/Contents/Source/PolySDLCore.cpp

@@ -160,8 +160,14 @@ void SDLCore::openURL(String url) {
     }
 }
 
-String SDLCore::executeExternalCommand(String command,  String inDirectory) {
-	FILE *fp = popen(command.c_str(), "r");
+String SDLCore::executeExternalCommand(String command, String args, String inDirectory) {
+	String finalCommand = command + " " + args;
+
+	if(inDirectory != "") {
+		finalCommand = "cd " + inDirectory + " && " + finalCommand;
+	}
+
+	FILE *fp = popen(finalCommand.c_str(), "r");
 	if(!fp) {
 		return "Unable to execute command";
 	}