Просмотр исходного кода

Made polybuild compile on Linux, no idea if it actually works.

Cameron Hart 14 лет назад
Родитель
Сommit
3a11b5b9c2
1 измененных файлов с 16 добавлено и 8 удалено
  1. 16 8
      Tools/Contents/polybuild/Source/polybuild.cpp

+ 16 - 8
Tools/Contents/polybuild/Source/polybuild.cpp

@@ -127,10 +127,10 @@ void addFolderToZip(zipFile z, String folderPath, String parentFolder, bool sile
 }
 
 #ifdef _WINDOWS
-void wtoc(char* Dest, TCHAR* Source, int SourceSize)
-{
-for(int i = 0; i < SourceSize; ++i)
-Dest[i] = (char)Source[i];
+void wtoc(char* Dest, TCHAR* Source, int SourceSize)
+{
+for(int i = 0; i < SourceSize; ++i)
+Dest[i] = (char)Source[i];
 }
 #endif
 
@@ -147,7 +147,7 @@ int main(int argc, char **argv) {
 		installPath = installPath + cpts[i];
 		installPath += String("/");
 	}
-#else
+#elseif defined (_WINDOWS)
 	char path[2049];
 	TCHAR tpath[2049];
 	GetModuleFileName(NULL, (LPWSTR)tpath, 2048);
@@ -160,7 +160,14 @@ int main(int argc, char **argv) {
 		installPath = installPath + cpts[i];
 		installPath += String("\\");
 	}
-
+#else
+	String basePath = PHYSFS_getBaseDir();
+	vector<String> cpts = basePath.split("/");
+	String installPath = "";
+	for(int i=0; i < cpts.size() - 2; i++) {
+		installPath = installPath + cpts[i];
+		installPath += String("/");
+	}
 #endif
 
 	printf("Polycode build tool v0.1.1\n");
@@ -191,11 +198,12 @@ int main(int argc, char **argv) {
 	char dirPath[4099];
 #if defined(__APPLE__) && defined(__MACH__)
 	_getcwd(dirPath, sizeof(dirPath));
-#else	
+#elseif defined (_WINDOWS)
 	TCHAR tdirpath[4099];
 	GetCurrentDirectory(4098, (LPWSTR)tdirpath);
 	wtoc(dirPath, tdirpath, 4098);
-
+#else
+	getcwd(dirPath, sizeof(dirPath));
 #endif
 	String currentPath = String(dirPath);