/** * Create a the URI for a (potentially non-existent) file to which we can * write. Typically this is used to store user preferences and application * overrides. This method of acquiring files is preferred over * getResourceProperties() as this is writable and can take into account * user preferences. This method makes no promise that the URI returned is * valid. It is totally untested, so reading may well cause errors. * * @param subject * The name (minus the .xxx extension) * @param extension * The extension, prefixed with a '.' See: {@link FileUtil} for a * list of popular extensions. * @return The resource as a URI */ public URI getWritableURI(String subject, String extension) { return NetUtil.lengthenURI(getWritableProjectDir(), subject + extension); }
private static void migrateBookDir() { // Books should be on this path URI userDataArea = OSType.getOSType().getUserAreaFolder(DIR_SWORD_CONF, DIR_SWORD_CONF_ALT); File swordBookPath = new File(userDataArea.getPath()); // The "old" Book location might be in one of two locations // It might be ~/.jsword or the new project dir File oldPath = new File(CWProject.instance().getDeprecatedWritableProjectDir().getPath()); if (oldPath.isDirectory()) { migrateBookDir(oldPath, swordBookPath); 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); } }
/** * A directory within the project directory. * * @param subject * A name for the subdirectory of the Project directory. * @param create whether to create the directory if it does not exist * @return A file: URI pointing at a local writable directory. * @throws IOException */ public URI getWritableProjectSubdir(String subject, boolean create) throws IOException { URI temp = NetUtil.lengthenURI(getWritableProjectDir(), subject); if (create && !NetUtil.isDirectory(temp)) { NetUtil.makeDirectory(temp); } return temp; }
testDefaultPath(bookDirs, new File(CWProject.instance().getWritableProjectDir().getPath()));
log.debug(("Main JSword path:"+CWProject.instance().getWritableProjectDir()));
File jswordHome = NetUtil.getAsFile(CWProject.instance().getWritableProjectDir()); IOUtil.unpackZip(NetUtil.getAsFile(temp), jswordHome, false, SwordConstants.DIR_CONF, SwordConstants.DIR_DATA);