/** * Locates the NetBeans cache directory. * This may be used to store pure performance caches - files which could be safely deleted, * since they would be automatically recreated on demand. * Each module is responsible for using sufficiently unique filenames within this directory. * {@code $userdir/var/cache/} is used as a default when {@link #getUserDirectory} is configured. * As a final fallback, a location in the system temporary directory will be returned. * @return a directory location (never null but need not yet exist) * @see #getCacheSubdirectory * @see #getCacheSubfile */ public static synchronized /*@NonNull*/ File getCacheDirectory() { Places places = Lookup.getDefault().lookup(Places.class); if (places != null) { File cache = places.findCacheDirectory(); if (cache != null) { return cache; } } File userdir = getUserDirectory(); if (userdir != null) { return new File(new File(userdir, "var"), "cache"); } return new File(System.getProperty("java.io.tmpdir"), "nbcache"); }
private static synchronized File getCacheFolder () { if (cacheFolder == null) { cacheFolder = Places.getCacheSubdirectory("sindex/1.0"); } return cacheFolder; }
/** * Convenience method to get a particular subdirectory within {@link #getCacheDirectory}. * The directory will be created if it does not yet exist (but a warning logged if permissions do not allow this). * @param path a subdirectory path such as {@code stuff} or {@code mymodule/stuff} ({@code /} permitted even on Windows) * @return a directory of that name within the general cache directory */ public static /*@NonNull*/ File getCacheSubdirectory(String path) { File d = new File(getCacheDirectory(), path); if (!d.isDirectory() && !d.mkdirs()) { LOG.log(Level.WARNING, "could not create {0}", d); } return d; }
private File getStorageRootFile() { return new File(new File(Places.getUserDirectory(), "config"), "issue-tracking"); // NOI18N }
File user = Places.getUserDirectory(); if (user != null) { AtomicInteger crc = new AtomicInteger(); sb.append("branding=").append(NbBundle.getBranding()).append('\n'); File checkSum = new File(Places.getCacheDirectory(), "lastModified/all-checksum.txt"); if (!compareAndUpdateFile(checkSum, sb.toString(), result)) { discardCachesImpl(result);
private static File getCacheFile(String name, int chapter, String platformName) { // name might look like "operator /=", so we need to escape it String safeName; try { safeName = URLEncoder.encode(name, "UTF-8"); // NOI18N } catch (UnsupportedEncodingException ex) { // UTF-8 should always be supported, but anyway... safeName = name; } return Places.getCacheSubfile("cnd/manpages/" + safeName + "." + platformName + "." + chapter); // NOI18N }
static File getStorageRootFile() { return new File(new File(Places.getUserDirectory(), "var"), "filehistory"); // NOI18N }
if (Places.getUserDirectory() != null) { stamp = new File(new File(Places.getCacheDirectory(), "lastModified"), clusterLocalStamp(cluster)); if (checkStampFile && (time = stamp.lastModified()) > 0) { if (time > result.longValue()) {
public static Dictionary getDictionary(String suffix, List<URL> sources) throws IOException { File trie = Places.getCacheSubfile("dict/dictionary" + suffix + ".trie" + CURRENT_TRIE_DICTIONARY_VERSION); return getDictionary(trie, sources); }
private File getStorageRootFile() { File userDir = Places.getUserDirectory(); return new File(new File(new File(userDir, "var"), "bugtracking"), "dashboard"); // NOI18N }
private File getCacheFile(Directive directive) { return Places.getCacheSubfile(new StringBuilder().append(CACHE_FOLDER_NAME).append('/').append(DOC_VERSION).append('/').append(directive.name()).toString()); }
private File getDefaultIndexLocation() { return Places.getCacheSubdirectory("mavenindex"); }
/** * Convenience method to get a particular file within {@link #getCacheDirectory}. * The parent directory will be created if it does not yet exist (but a warning logged if permissions do not allow this); * the file itself will not be automatically created. * @param path a file path such as {@code stuff.ser} or {@code mymodule/stuff.ser} ({@code /} permitted even on Windows) * @return a file of that name within the general cache directory */ public static /*@NonNull*/ File getCacheSubfile(String path) { File f = new File(getCacheDirectory(), path); File d = f.getParentFile(); if (!d.isDirectory() && !d.mkdirs()) { LOG.log(Level.WARNING, "could not create {0}", d); } return f; }
/** Tries to set permissions on preferences storage file to -rw------- */ public static void goMinusR(Preferences p) { File props = new File(Places.getUserDirectory(), ("config/Preferences" + p.absolutePath()).replace('/', File.separatorChar) + ".properties"); if (props.isFile()) { props.setReadable(false, false); // seems to be necessary, not sure why props.setReadable(true, true); LOG.log(Level.FINE, "chmod go-r {0}", props); } else { LOG.log(Level.FINE, "no such file to chmod: {0}", props); } }
File cacheFile = Places.getCacheSubfile(cache); long last = cacheFile.lastModified(); if (last <= 0) {
private static File getDefaultCacheLocation() { return Places.getCacheSubdirectory("cnd/model"); // NOI18N }
@Override public FileObject getCacheDirectory() throws IOException { synchronized (lock) { if (cacheDirectory == null) { File cacheFile = getCacheLocation(projectDirectory); if (cacheFile == null) { // TODO: find more elegant soluition than duplicating "cnd.repository.cache.path" in CacheLocation and MakeProject // What we can do is our own Places impl. that delegates to the next Places impl. if this property is not set; is it worth doing? String path = System.getProperty("cnd.repository.cache.path"); if (path == null) { cacheFile = Places.getCacheDirectory(); } else { cacheFile = new File(path); } } cacheDirectory = FileUtil.createFolder(cacheFile); } return cacheDirectory; } }
public static synchronized DictionaryImpl getUsersLocalDictionary(Locale locale) { DictionaryImpl d = locale2UsersLocalDictionary.get(locale); if (d != null) return d; File cache = new File(Places.getUserDirectory(), "private-dictionary-" + locale.toString()); locale2UsersLocalDictionary.put(locale, d = new DictionaryImpl(cache, locale)); return d; }
private File getCachedAPIFile() { if (apiFile != null) { return apiFile; } if (docFolder != null) { for (FileObject folder : Collections.list(docFolder.getFolders(false))) { FileObject fo = folder.getFileObject(API_ALL_JSON_FILE); if (fo != null) { apiFile = FileUtil.toFile(fo); return apiFile; } } } File cacheFile = Places.getCacheSubfile(docApiFilePath); return cacheFile; }
public LayerDescriptor getDefault() { File file = Places.getCacheSubdirectory("cnd/model"); // NOI18N URI uri = Utilities.toURI(file); LayerDescriptor layerDescriptor = new LayerDescriptor(uri); return layerDescriptor; }