List of usage examples for java.io File equals
public boolean equals(Object obj)
From source file:com.igormaznitsa.sciareto.ui.tabs.TabTitle.java
public boolean belongFolderOrSame(@Nonnull final File folder) { boolean result = false; if (this.associatedFile != null) { return folder.equals(this.associatedFile) || Paths.toPath(this.associatedFile).startsWith(Paths.toPath(folder)); }/*from w w w . j a va 2 s .c o m*/ return result; }
From source file:org.jboss.tools.central.internal.discovery.wizards.ProxyWizardManager.java
/** * Deletes the oldest cache folders/*from ww w . j a v a 2 s.c o m*/ * * @param nbKeptFolders the number of most recent cache folders to keep * @param monitor */ void purgeOldCacheFolders(int nbKeptFolders, IProgressMonitor monitor) { File[] files = getCacheFolders(true); if (files == null || files.length <= nbKeptFolders) { return; } File currentCache = getCurrentCacheFolder(); int i = files.length; while (i > nbKeptFolders && i > 0) { if (monitor.isCanceled()) { return; } File f = files[--i]; if (!f.equals(currentCache)) { FileUtils.deleteQuietly(f); } } }
From source file:fr.gael.dhus.datastore.IncomingManager.java
public boolean isInIncoming(File path) { File root = new File(cfgManager.getArchiveConfiguration().getIncomingConfiguration().getPath()); if (path == null) return false; if (path.equals(root)) return true; else// w ww .ja v a2s . c o m return isInIncoming(path.getParentFile()); }
From source file:de.jcup.egradle.eclipse.ide.IDEUtil.java
/** * Calculates if given project is a sub project for current root. If no root * project is setup, this method will always return false. * /*from w w w. j a v a 2s.c o m*/ * @param p * @return <code>true</code> when project is sub project of current root * project * @throws CoreException */ public static boolean isSubprojectOfCurrentRootProject(IProject p) throws CoreException { if (p == null) { return false; } if (!p.exists()) { return false; } File rootFolder = getRootProjectFolderWithoutErrorHandling(); if (rootFolder == null) { return false; } IPath path = p.getLocation(); File parentFolder = getResourceHelper().toFile(path); if (parentFolder == null) { return false; } if (!parentFolder.exists()) { return false; } if (!rootFolder.equals(parentFolder)) { parentFolder = parentFolder.getParentFile(); } if (!rootFolder.equals(parentFolder)) { return false; } return true; }
From source file:edu.umn.msi.tropix.storage.core.monitor.StorageMonitorClosureImpl.java
private void registerFile(final File newFile) { final String newId = UUID.randomUUID().toString(); // It is perhaps inappropriate to pick id here final File rootDirectory = findMatchingDirectory(newFile); if (newFile.equals(rootDirectory)) { return;//from w w w. j av a 2 s . c o m } final List<String> extractPathList = Lists.newArrayList(); File parent = newFile.getParentFile(); while (!rootDirectory.equals(parent)) { extractPathList.add(parent.getName()); parent = parent.getParentFile(); } Collections.reverse(extractPathList); final String rootFolderName = monitorConfig.getSharedFolderName(rootDirectory); final VirtualFolder rootSharedFolder = folderService.getOrCreateRootVirtualFolderWithName(getIdentity(), rootFolderName); final VirtualFolder child = folderService.getOrCreateVirtualPath(getIdentity(), rootSharedFolder.getId(), Iterables.toArray(extractPathList, String.class)); final TropixFile tropixFile = new TropixFile(); tropixFile.setFileId(newId); tropixFile.setCommitted(true); tropixFile.setName(newFile.getName()); // TODO: FIX THIS // tropixFile.setFileSize(newFile.length()); tropixFile.setStorageServiceUrl(storageServiceUrl); persistentFileMapperService.registerMapping(newId, FilenameUtils.normalize(newFile.getAbsolutePath())); final TropixFile returnedFile = tropixObjectService.createFile(getIdentity(), child.getId(), tropixFile, null); fileService.recordLength(newId, newFile.length()); tropixObjectService.addToSharedFolder(getIdentity(), returnedFile.getId(), child.getId(), false); }
From source file:org.nuxeo.ecm.webengine.model.impl.ModuleManager.java
public ModuleConfiguration getModuleByConfigFile(File file) { ModuleConfiguration[] ar = getModules(); for (ModuleConfiguration mc : ar) { if (file.equals(mc.file)) { return mc; }/*from w w w . ja v a 2 s. c o m*/ } return null; }
From source file:org.paxle.core.doc.impl.CachedParserDocument.java
@Override public void setTextFile(File file) throws IOException { // closing old streams this.close(); // releasing old temp-file if (file != null && !file.equals(this.contentFile)) { if (this.tempFileManager != null && this.tempFileManager.isKnown(this.contentFile)) { this.tempFileManager.releaseTempFile(this.contentFile); }/*w ww .j a v a2s . co m*/ } // initiialize internal structure this.contentWriter = null; this.contentStream = null; this.contentFile = file; if (file != null && file.exists() && file.length() > 0) { /* * If the file already contains data, we must not create an in-memory-writer. * Therefore we create a simple FileOutputStream here */ this.contentStream = new BufferedOutputStream(new FileOutputStream(this.contentFile, true)); } }
From source file:org.hyperic.hq.stats.AbstractStatsWriter.java
private final void cleanupFilename(String filename) { final File file = new File(filename); final File path = file.getParentFile(); final String name = file.getName(); final FilenameFilter filter = new FilenameFilter() { final String _filename = name; public boolean accept(File dir, String name) { if (dir.equals(path) && name.startsWith(_filename)) { return true; }/*from ww w . jav a2 s. c om*/ return false; } }; final File[] files = path.listFiles(filter); final long oneWeekAgo = System.currentTimeMillis() - (7 * MeasurementConstants.DAY); for (int i = 0; i < files.length; i++) { if (files[i].lastModified() < oneWeekAgo) { files[i].delete(); } } }
From source file:org.duracloud.sync.monitor.DirectoryUpdateMonitor.java
/** * Creates a directory update monitor which, when started, will notify * on changes within the given directories. * * @param directories to monitor//from w w w.j a v a 2s.c om * @param pollFrequency how often the monitor should look for changes */ public DirectoryUpdateMonitor(List<File> directories, long pollFrequency, boolean syncDeletes) { monitor = new FileAlterationMonitor(pollFrequency); for (File watchDir : directories) { if (watchDir.exists()) { FileAlterationObserver observer; if (watchDir.isDirectory()) { observer = new FileAlterationObserver(watchDir); } else { final File file = watchDir; observer = new FileAlterationObserver(watchDir.getParentFile(), new FileFilter() { @Override public boolean accept(File pathname) { return (file.equals(pathname)); } }); } observer.addListener(new DirectoryListener(syncDeletes)); monitor.addObserver(observer); } else { throw new RuntimeException("Path " + watchDir.getAbsolutePath() + " does not exist"); } } }
From source file:io.warp10.quasar.trl.QuasarTokenRevocationListLoader.java
private String[] getFolderFiles(String path) { final File root = new File(path); String[] files = root.list(new FilenameFilter() { @Override//from w w w. j a v a 2s .co m public boolean accept(File d, String name) { if (!d.equals(root)) { return false; } return name.matches(trlPattern); } }); // Sort files in lexicographic order if (null == files) { files = new String[0]; } Arrays.sort(files); return files; }