From 9e3f1f2253dc967ab6f5824410ab11771c768b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Pol=C3=A1k?= Date: Tue, 29 Oct 2013 23:25:42 +0100 Subject: [PATCH] rel2abs java.library.path.N --- WinRun4J/src/java/VM.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/WinRun4J/src/java/VM.cpp b/WinRun4J/src/java/VM.cpp index e659e9b..0acd4ff 100644 --- a/WinRun4J/src/java/VM.cpp +++ b/WinRun4J/src/java/VM.cpp @@ -371,14 +371,34 @@ void VM::ExtractSpecificVMArgs(dictionary* ini, TCHAR** args, UINT& count) UINT libPathsCount = 0; INI::GetNumberedKeysFromIni(ini, JAVA_LIBRARY_PATH, libPaths, libPathsCount); if(libPathsCount > 0) { + + //toPeter: Sorry I am repeating the same code, i really hate it but I cannot afford a refactoring right now, duplicit to #83 row + // If the working.dir is not specified then we assume the java.library.path location is relative to the module dir + char defWorkingDir[MAX_PATH]; + char* workingDir = iniparser_getstr(ini, WORKING_DIR); + if(!workingDir) { + GetCurrentDirectory(MAX_PATH, defWorkingDir); + SetCurrentDirectory(iniparser_getstr(ini, INI_DIR)); + } + TCHAR libPathArg[4096]; libPathArg[0] = 0; strcat(libPathArg, "-Djava.library.path="); for(int i =0 ; i < libPathsCount; i++) { - strcat(libPathArg, libPaths[i]); + + //rel2abs + char fullpath[MAX_PATH]; + GetFullPathName(libPaths[i], MAX_PATH, fullpath, NULL); + strcat(libPathArg, fullpath); strcat(libPathArg, ";"); } args[count++] = strdup(libPathArg); + + //toPeter: Sorry I am repeating the same code, i really hate it but I cannot afford a refactoring right now, duplicit to #119 row + // Reset working dir if set + if(!workingDir) { + SetCurrentDirectory(defWorkingDir); + } } }