List of usage examples for java.io File equals
public boolean equals(Object obj)
From source file:eionet.gdem.utils.Utils.java
/** * Deletes the folder, where specified file locates. * * @param filePath//from w w w .j av a2s . c om */ public static void deleteParentFolder(String filePath) { File file = new File(filePath); String folder = file.getParent(); // check if the folder is not Properties.tmpFolder File oFolder = new File(folder); File oTmpFolder = new File(Properties.tmpFolder); // if parent folder is system tmp folder, then delete only the // specifieds file if (oFolder.equals(oTmpFolder)) { deleteFile(filePath); } else { deleteFolder(folder); } }
From source file:org.archive.crawler.framework.ActionDirectory.java
/** * Process an individual action file found * // ww w .j a va2s . c o m * @param actionFile File to process */ protected void actOn(File actionFile) { LOGGER.info("processing action file: " + actionFile); String filename = actionFile.getName(); boolean isGzip = filename.endsWith(".gz"); String corename = isGzip ? filename.substring(0, filename.length() - 3) : filename; String timestamp = ArchiveUtils.get17DigitDate(); if (corename.endsWith(".seeds")) { // import seeds getSeeds().actOn(actionFile); } else if (corename.endsWith(".recover")) { // apply recovery-log boolean alsoScope = corename.endsWith(".s.recover"); try { // consider-included all successes and explicit-includes... getFrontier().importRecoverFormat(actionFile, alsoScope, true, false, "F[si] "); // then retry all adds... getFrontier().importRecoverFormat(actionFile, alsoScope, false, false, "F\\+ "); } catch (IOException ioe) { LOGGER.log(Level.SEVERE, "problem with action file: " + actionFile, ioe); } } else if (corename.endsWith(".include")) { // consider-included-only (do not schedule) boolean alsoScope = corename.endsWith(".s.include"); try { getFrontier().importRecoverFormat(actionFile, alsoScope, true, false, ".*"); } catch (IOException ioe) { LOGGER.log(Level.SEVERE, "problem with action file: " + actionFile, ioe); } } else if (corename.endsWith(".schedule")) { // schedule to queues boolean alsoScope = corename.endsWith(".s.schedule"); try { getFrontier().importRecoverFormat(actionFile, alsoScope, false, false, ".*"); } catch (IOException ioe) { LOGGER.log(Level.SEVERE, "problem with action file: " + actionFile, ioe); } } else if (corename.endsWith(".force")) { // schedule to queues boolean alsoScope = corename.endsWith(".s.force"); try { getFrontier().importRecoverFormat(actionFile, alsoScope, false, true, ".*"); } catch (IOException ioe) { LOGGER.log(Level.SEVERE, "problem with action file: " + actionFile, ioe); } // } else if (filename.endsWith(".robots")) { // // force refresh of robots // // TODO } else if (!tryAsScript(actionFile, timestamp)) { LOGGER.warning("action file ignored: " + actionFile); } // move file to 'done' area with timestamp prefix while (actionFile.exists()) { try { File doneFile = new File(doneDir.getFile(), timestamp + "." + actionFile.getName()); FileUtils.moveFile(actionFile, doneFile); // attempt to symlink from action/done/ to done file File actionDoneDirFile = new File(actionDir.getFile(), "done"); if (!actionDoneDirFile.equals(doneDir.getFile())) { actionDoneDirFile.mkdirs(); File doneSymlinkFile = new File(actionDoneDirFile, doneFile.getName()); boolean success = FilesystemLinkMaker.makeSymbolicLink(doneFile.getPath(), doneSymlinkFile.getPath()); if (!success) { LOGGER.warning("failed to create symlink from " + doneSymlinkFile + " to " + doneFile); } } } catch (IOException e) { LOGGER.log(Level.SEVERE, "unable to move " + actionFile, e); } } }
From source file:org.openthinclient.util.dpkg.DPKGPackageManager.java
/** * Check if the given file represents the "root" entry relative to the given baseDirectory. * * @param baseDirectory the directory serving as a "virtual root" * @param file the file to be compared agains the base dir * @return <code>true</code> if the file represents the relative root *//*from ww w. j a v a2 s . c o m*/ private boolean isRoot(File baseDirectory, File file) { return baseDirectory.equals(file); }
From source file:com.servoy.extension.install.LibActivationHandler.java
private String getJNLPHrefFromRelativePath(String libPathToActivate) { File appServerDir = new File(installDir, APP_SERVER_DIR); File f = new File(installDir, libPathToActivate); String result = f.getName();//from w w w . j av a 2 s . co m while (!appServerDir.equals(f.getParentFile()) && !installDir.equals(f.getParentFile())) { f = f.getParentFile(); result = f.getName() + "/" + result; //$NON-NLS-1$ } if (installDir.equals(f.getParentFile())) { result = "../" + result; //$NON-NLS-1$ } result = "/" + result; //$NON-NLS-1$ return result; // must be relative to app. server dir }
From source file:org.apache.ivy.core.retrieve.RetrieveTest.java
private void assertLink(String filename) throws IOException { // if the OS is known to support symlink, check that the file is a symlink, // otherwise just check the file exist. File file = new File(filename); assertTrue("The file " + filename + " doesn't exist", file.exists()); String os = System.getProperty("os.name"); if (os.equals("Linux") || os.equals("Solaris") || os.equals("FreeBSD") || os.equals("Mac OS X")) { // these OS should support symnlink, so check that the file is actually a symlink. // this is done be checking that the canonical path is different from the absolute // path.//from w w w .ja v a 2 s . co m File absFile = file.getAbsoluteFile(); File canFile = file.getCanonicalFile(); assertFalse("The file " + filename + " isn't a symlink", absFile.equals(canFile)); } }
From source file:de.jcup.egradle.core.util.FileSupport.java
public boolean isDirectSubFolder(File folder, File expectedParentFolder) { if (folder == null) { return false; }//from w ww. ja va 2 s .com if (expectedParentFolder == null) { return false; } if (expectedParentFolder.equals(folder.getParentFile())) { return true; } return false; }
From source file:org.opencastproject.composer.impl.EncodingProfileScanner.java
/** * {@inheritDoc}//from w w w. j av a2 s. com * * @see org.apache.felix.fileinstall.ArtifactInstaller#uninstall(java.io.File) */ @Override public void uninstall(File artifact) throws Exception { for (Iterator<EncodingProfile> iter = profiles.values().iterator(); iter.hasNext();) { EncodingProfile profile = iter.next(); if (artifact.equals(profile.getSource())) { logger.info("Uninstalling profile {}", profile.getIdentifier()); iter.remove(); } } }
From source file:com.microsoft.tfs.client.common.wit.QueryDocumentService.java
public boolean hasQueryDocumentForFile(final File file) { Check.notNull(file, "file"); //$NON-NLS-1$ synchronized (queriesLock) { for (final Iterator<QueryDocumentWrapper> it = queries.iterator(); it.hasNext();) { final QueryDocumentWrapper wrapper = it.next(); if (file.equals(wrapper.queryDocument.getFile())) { return true; }/*from w ww . j a v a 2 s . c om*/ } } return false; }
From source file:org.openflexo.foundation.resource.ResourceRepository.java
/** * Get the set of path in the case of File * /* w w w. j a v a 2 s .com*/ * @param aFile * @return * @throws IOException */ private List<String> getPathTo(File aFile) throws IOException { if (FileUtils.directoryContainsFile(getRootFolder().getFile(), aFile, true)) { List<String> pathTo = new ArrayList<String>(); File f = aFile.getParentFile().getCanonicalFile(); while (f != null && !f.equals(getRootFolder().getFile().getCanonicalFile())) { pathTo.add(0, f.getName()); f = f.getParentFile(); } return pathTo; } else { return null; } }
From source file:org.opendatakit.utilities.ODKFileUtils.java
/** * Returns the relative path beginning after the getAppFolder(appName) directory. * The relative path does not start or end with a '/' * * @param appName the app name/*from w ww . j a va 2 s. c o m*/ * @param fileUnderAppName a file that's under :app_name/ * @return a relative path to that file */ public static String asRelativePath(String appName, File fileUnderAppName) { // convert fileUnderAppName to a relative path such that if // we just append it to the AppFolder, we have a full path. File parentDir = new File(getAppFolder(appName)); ArrayList<String> pathElements = new ArrayList<>(); File f = fileUnderAppName; while (f != null && !f.equals(parentDir)) { pathElements.add(f.getName()); f = f.getParentFile(); } if (f == null) { throw new IllegalArgumentException("file is not located under this appName (" + appName + ")!"); } StringBuilder b = new StringBuilder(); for (int i = pathElements.size() - 1; i >= 0; --i) { String element = pathElements.get(i); b.append(element); if (i != 0) { b.append(File.separator); } } return b.toString(); }