Subversion Repository Public Repository

litesoft

Diff Revisions 361 vs 889 for /trunk/Java/ScarPlus/src/com/esotericsoftware/scar/Utils.java

Diff revisions: vs.
  @@ -8,6 +8,7 @@
8 8
9 9 import com.esotericsoftware.utils.*;
10 10
11 + @SuppressWarnings("UnusedDeclaration")
11 12 public class Utils extends FileUtil
12 13 {
13 14 /**
  @@ -67,6 +68,48 @@
67 68 return fileName;
68 69 }
69 70
71 + static public File findCommonDirPathFromCanonicalDirPaths( File pPath1, File pPath2 )
72 + {
73 + String zPath1 = pPath1.getPath();
74 + String zPath2 = pPath2.getPath();
75 + if (zPath2.startsWith(zPath1)) // Check the Happy Cases
76 + {
77 + return pPath1;
78 + }
79 + if (zPath1.startsWith(zPath2))
80 + {
81 + return pPath2;
82 + }
83 + String zSharedPath = findSharedPath( zPath1, zPath2 );
84 + if ( zSharedPath.length() != 0 )
85 + {
86 + for ( File zShared = new File( zSharedPath ); zShared != null; zShared = zShared.getParentFile() )
87 + {
88 + if ( zShared.isDirectory() )
89 + {
90 + return zShared;
91 + }
92 + }
93 + }
94 + return null;
95 + }
96 +
97 + static private String findSharedPath( String pPath1, String pPath2 )
98 + {
99 + int zLength = Math.min(pPath1.length(), pPath2.length());
100 + if ( (zLength == 0) || (pPath1.charAt(0) != pPath2.charAt(0)) )
101 + {
102 + return "";
103 + }
104 + for (int i = 1; i < zLength; i++) {
105 + if ( pPath1.charAt( i ) != pPath2.charAt( i ) )
106 + {
107 + return pPath1.substring( 0, i ); // i == Exclusive
108 + }
109 + }
110 + return pPath1.substring( 0, zLength );
111 + }
112 +
70 113 /**
71 114 * Returns the canonical path for the specified path. Eg, if "." is passed, this will resolve the actual path and return it.
72 115 */
  @@ -295,8 +338,9 @@
295 338 LOGGER.debug.log( "Creating keystore (", alias, ":", password, ", ", company, ", ", title, "): ", keystoreFile );
296 339
297 340 File file = new File( keystoreFile );
341 + //noinspection ResultOfMethodCallIgnored
298 342 file.delete();
299 - Process process = null;
343 + Process process;
300 344 try
301 345 {
302 346 process = Runtime.getRuntime().exec( new String[]{resolvePath( "keytool" ), "-genkey", "-keystore", keystoreFile, "-alias", alias} );