public URI getPropertyFileURI() { return CWProject.instance().getWritableURI(LuceneIndexManager.DIR_LUCENE + "/" + getClass().getName(), FileUtil.EXTENSION_PROPERTIES); }
/** * Required for reset of statics during testing */ @SuppressWarnings("unused") private static void reset() { instance = new CWProject(); }
/** * Establish how this project finds it's resources. * * @param homeProperty * a property that is used as the home directory name. If this * property has a value then homeDir and altHomeDir are ignored. * Defaults to jsword.home. * @param homeDir * the name of the directory to be used for Unix. Typically this * is a hidden directory, that is, it begins with a '.'. Defaults * to .jsword * @param altHomeDir * the name of the directory to be used for other OSes. This * should not be a hidden directory. Defaults to JSword. */ public static void setHome(String homeProperty, String homeDir, String altHomeDir) { CWProject.homeProperty = homeProperty; CWProject.homeDirectory = homeDir; CWProject.homeAltDirectory = altHomeDir; instance().establishProjectHome(); }
@Override public File getWriteLocation() { return getFile(CWProject.instance().getWritableFrontendProjectDir()); } };
CWProject.instance().setFrontendName("and-bible"); enableDefaultAndManualInstallFolder(); } else { CWProject.setHome("jsword.home", moduleDir.getAbsolutePath(), null); log.debug(("Main JSword path:"+CWProject.instance().getWritableProjectDir()));
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); } }
testDefaultPath(bookDirs, new File(CWProject.instance().getWritableProjectDir().getPath()));
URI oldPath = getDeprecatedWritableProjectDir(); writeHome = migrateUserProjectDir(oldPath, path); CWClassLoader.setHome(getProjectResourceDirs()); URI uricache = getWritableProjectSubdir(DIR_NETCACHE, true); File filecache = new File(uricache.getPath()); NetUtil.setURICacheDir(filecache); this.writableFrontEndHome = getWritableProjectSubdir(this.frontendName, true);
@Override public File getReadLocation() { URI[] dirs = CWProject.instance().getProjectResourceDirs(); if (dirs.length > 1) { return getFile(dirs[1]); } return null; } @Override
/** * Create a LuceneIndexManager with a default IndexPolicy. */ public LuceneIndexManager() { policy = new IndexPolicyAdapter(); try { baseFolderURI = CWProject.instance().getWritableProjectSubdir(DIR_LUCENE, false); } catch (IOException ex) { log.error("Failed to find lucene index storage area.", ex); } }
@Override public File getReadLocation() { return getFile(CWProject.instance().getReadableFrontendProjectDir()); } @Override
/** * 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); }
/** * @return the readable home for the front-end settings, that can be kept separate from JSword's * configuration, as well from other front-ends. */ public URI getReadableFrontendProjectDir() { establishProjectHome(); return this.frontendReadHome; }
File jswordHome = NetUtil.getAsFile(CWProject.instance().getWritableProjectDir()); IOUtil.unpackZip(NetUtil.getAsFile(temp), jswordHome, false, SwordConstants.DIR_CONF, SwordConstants.DIR_DATA);
@Override public File getWriteLocation() { URI[] dirs = CWProject.instance().getProjectResourceDirs(); if (dirs.length > 0) { return getFile(dirs[0]); } return null; } },
/** * The URL for the cached index file for this installer */ protected URI getCachedIndexDir() throws InstallException { try { return CWProject.instance().getWritableProjectSubdir(getTempFileExtension(host, catalogDirectory), true); } catch (IOException ex) { throw new InstallException(JSOtherMsg.lookupText("URL manipulation failed"), ex); } }
/** * 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; }
/** * Get the writable user project directory. * * @return the writable user project directory. */ public URI getWritableProjectDir() { establishProjectHome(); return writeHome; }
/** * @param newShown * Whether this WebWarning should be shown. */ public void setShown(boolean newShown) { try { shown = newShown; PropertyMap props = new PropertyMap(); props.put(SHOWN_KEY, Boolean.valueOf(shown).toString()); URI outputURI = CWProject.instance().getWritableURI(getClass().getName(), FileUtil.EXTENSION_PROPERTIES); NetUtil.storeProperties(props, outputURI, "JSword WebWarning"); } catch (IOException ex) { log.error("Failed to save JSword WebWarning", ex); } }
/** * @return the writable home for the front-end settings, that can be kept separate from JSword's * configuration, as well from other front-ends. */ public URI getWritableFrontendProjectDir() { establishProjectHome(); return this.writableFrontEndHome; }