Browse Source

small changes for linux saving. Crossplattform saving/loading should work now

Teh-Hai Julian Zheng 7 years ago
parent
commit
97faf6aea5
2 changed files with 24 additions and 19 deletions
  1. 11 10
      src/ui/controller/LoadController.java
  2. 13 9
      src/ui/controller/SaveController.java

+ 11 - 10
src/ui/controller/LoadController.java

@@ -291,9 +291,10 @@ public class LoadController {
 
 	private String refreshPath(String image) {
 		// TODO Auto-generated method stub
-		if(!image.contains("/HolonGUI/"))
+		if (!image.contains("/HolonGUI/"))
 			return image;
-		return (System.getProperty("user.home") + image.substring(image.indexOf("/HolonGUI/"), image.length())).replace("\\", "/");
+		return (System.getProperty("user.home") + image.substring(image.indexOf("/HolonGUI/"), image.length()))
+				.replace("\\", "/");
 	}
 
 	/**
@@ -497,7 +498,7 @@ public class LoadController {
 
 		ArchiveEntry entry = stream.getNextEntry();
 		while (entry != null) {
-//			String entryName = checkOS(entry.getName());
+			// String entryName = checkOS(entry.getName());
 			File file = new File(tmp, entry.getName());
 			file.getParentFile().mkdirs();
 			OutputStream output = new FileOutputStream(file);
@@ -518,27 +519,27 @@ public class LoadController {
 		String os = System.getProperty("os.name").toLowerCase();
 		String ret = entryName;
 		String partition = System.getProperty("user.home");
-		
-		if(!ret.contains("HolonGUI"))
+
+		if (!ret.contains("HolonGUI"))
 			return ret;
 
 		if (os.contains("windows")) {
 			ret = ret.replace("/", "\\");
 			ret = System.getProperty("user.home") + ret.substring(ret.indexOf("\\HolonGUI\\"), ret.length());
-			
+
 		}
 		if (os.contains("mac")) {
-			//dosmth
+			// dosmth
 			ret = ret.replace("\\", "/");
 			ret = System.getProperty("user.home") + ret.substring(ret.indexOf("/HolonGUI/"), ret.length());
 		}
 		if (os.contains("linux")) {
-			//dosmth
+			// dosmth
 			ret = ret.replace("\\", "/");
 			ret = System.getProperty("user.home") + ret.substring(ret.indexOf("/HolonGUI/"), ret.length());
 		}
-		if(os.contains("solaris")) {
-			//dosmth
+		if (os.contains("solaris")) {
+			// dosmth
 		}
 		return ret;
 	}

+ 13 - 9
src/ui/controller/SaveController.java

@@ -417,8 +417,7 @@ public class SaveController {
 		// TODO Auto-generated method stub
 		JsonObject temp = new JsonObject();
 		String key = null;
-		
-		
+
 	}
 
 	/**
@@ -454,7 +453,7 @@ public class SaveController {
 	 */
 	private void addFileToSave(File src, ArchiveOutputStream stream, boolean dir) throws IOException {
 		String entryName = (dir == true ? src.getCanonicalPath() : src.getName());
-		
+
 		entryName = checkOS(entryName);
 
 		ZipArchiveEntry entry = new ZipArchiveEntry(entryName);
@@ -472,16 +471,21 @@ public class SaveController {
 		String ret = entryName;
 		String partition = null;
 
-		if(os.contains("windows")) { 
-			partition = ret.substring(0, ret.indexOf(":")+1);
+		if (os.contains("windows")) {
+			partition = ret.substring(0, ret.indexOf(":") + 1);
 			ret = ret.replace(System.getProperty("user.home") + "\\HolonGUI\\", "");
 			ret = ret.replace(partition, "");
 		}
-		if(os.contains("mac")) {
+		if (os.contains("mac")) {
+			// dosmth
 			ret = ret.replace(System.getProperty("user.home") + "/HolonGUI/", "");
 		}
-		if(os.contains("linux")) {
-			
+		if (os.contains("linux")) {
+			// dosmth
+			ret = ret.replace(System.getProperty("user.home") + "/HolonGUI/", "");
+		}
+		if (os.contains("solaris")) {
+			// dosmth
 		}
 		return ret;
 	}
@@ -534,7 +538,7 @@ public class SaveController {
 			return nUnitGraph++;
 		case STATSGRAPH:
 			return nStatsGraph++;
-		
+
 		default:
 			break;
 		}