[jsword-svn] r1875 - in trunk: common/src/main/java/org/crosswire/common/util jsword/src/main/java/org/crosswire/jsword/book/sword
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Wed Jun 11 13:55:40 MST 2008
Author: dmsmith
Date: 2008-06-11 13:55:40 -0700 (Wed, 11 Jun 2008)
New Revision: 1875
Modified:
trunk/common/src/main/java/org/crosswire/common/util/NetUtil.java
trunk/common/src/main/java/org/crosswire/common/util/OSType.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java
Log:
fixing a win32 bug
Modified: trunk/common/src/main/java/org/crosswire/common/util/NetUtil.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/NetUtil.java 2008-06-10 21:40:19 UTC (rev 1874)
+++ trunk/common/src/main/java/org/crosswire/common/util/NetUtil.java 2008-06-11 20:55:40 UTC (rev 1875)
@@ -401,39 +401,33 @@
String extra = anExtra;
try
{
+ StringBuffer path = new StringBuffer(orig.getPath());
+ char lastChar = path.charAt(path.length() - 1);
char firstChar = extra.charAt(0);
if (isSeparator(firstChar))
{
- extra = extra.substring(1);
- }
-
- if (orig.getScheme().equals(PROTOCOL_FILE))
- {
- String file = orig.toString();
- char lastChar = file.charAt(file.length() - 1);
if (isSeparator(lastChar))
{
- return new URI(orig.getScheme(),
- orig.getUserInfo(),
- orig.getHost(),
- orig.getPort(),
- orig.getPath() + extra,
- orig.getQuery(),
- orig.getFragment());
+ path.append(extra.substring(1));
}
- return new URI(orig.getScheme(),
- orig.getUserInfo(),
- orig.getHost(),
- orig.getPort(),
- orig.getPath() + File.separator + extra,
- orig.getQuery(),
- orig.getFragment());
+ else
+ {
+ path.append(extra);
+ }
}
+ else {
+ if (!isSeparator(lastChar))
+ {
+ path.append(SEPARATOR);
+ }
+ path.append(extra);
+ }
+
return new URI(orig.getScheme(),
orig.getUserInfo(),
orig.getHost(),
orig.getPort(),
- orig.getPath() + SEPARATOR + extra,
+ path.toString(),
orig.getQuery(),
orig.getFragment());
}
Modified: trunk/common/src/main/java/org/crosswire/common/util/OSType.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/OSType.java 2008-06-10 21:40:19 UTC (rev 1874)
+++ trunk/common/src/main/java/org/crosswire/common/util/OSType.java 2008-06-11 20:55:40 UTC (rev 1875)
@@ -34,7 +34,7 @@
*/
public abstract class OSType implements Serializable
{
- public static final OSType MAC = new OSType("Mac OS X") //$NON-NLS-1$
+ public static final OSType MAC = new OSType("Mac") //$NON-NLS-1$
{
/* (non-Javadoc)
* @see org.crosswire.jsword.util.OSType#getUserArea()
@@ -62,7 +62,7 @@
private static final long serialVersionUID = -1575982665011980783L;
};
- public static final OSType WIN32 = new OSType("Windows") //$NON-NLS-1$
+ public static final OSType WIN32 = new OSType("Win") //$NON-NLS-1$
{
/* (non-Javadoc)
* @see org.crosswire.jsword.util.OSType#getUserArea()
@@ -184,7 +184,7 @@
for (int i = 0; i < VALUES.length; i++)
{
OSType o = VALUES[i];
- if (o.name.startsWith(name))
+ if (name.startsWith(o.name))
{
return o;
}
@@ -271,4 +271,9 @@
* The user's home directory.
*/
private static URI userHome;
+
+ /**
+ * Serialization ID
+ */
+ private static final long serialVersionUID = -3196320305857293885L;
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java 2008-06-10 21:40:19 UTC (rev 1874)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java 2008-06-11 20:55:40 UTC (rev 1875)
@@ -324,12 +324,22 @@
return;
}
+ // now trying the new project dir
oldPath = new File(CWProject.instance().getWritableProjectDir().getPath());
if (oldPath.isDirectory())
{
migrateBookDir(oldPath, swordBookPath);
+ return;
}
+
+
+ // Finally, it might be ~/.sword
+ oldPath = new File(OSType.DEFAULT.getUserAreaFolder(DIR_SWORD_CONF, DIR_SWORD_CONF_ALT).getPath());
+ if (oldPath.isDirectory())
+ {
+ migrateBookDir(oldPath, swordBookPath);
+ }
}
private static void migrateBookDir(File oldPath, File newPath)
More information about the jsword-svn
mailing list