/** * Attempts tp determine whether both files are on different volumes. Returns true if we could determine that * the files are on different volumes. Returns false otherwise or if an error occurred while doing the check. * * @param srcFile * @param targetFile * @return true if on different volumes, false otherwise or if an error occurred */ boolean areOnDifferentVolumes(File srcFile, File targetFile) throws RolloverFailure { if (!EnvUtil.isJDK7OrHigher()) return false; File parentOfTarget = targetFile.getParentFile(); try { boolean onSameFileStore = FileStoreUtil.areOnSameFileStore(srcFile, parentOfTarget); return !onSameFileStore; } catch (RolloverFailure rf) { addWarn("Error while checking file store equality", rf); return false; } }
/** * Attempts tp determine whether both files are on different volumes. Returns true if we could determine that * the files are on different volumes. Returns false otherwise or if an error occurred while doing the check. * * @param srcFile * @param targetFile * @return true if on different volumes, false otherwise or if an error occurred */ boolean areOnDifferentVolumes(File srcFile, File targetFile) throws RolloverFailure { if (!EnvUtil.isJDK7OrHigher()) return false; File parentOfTarget = targetFile.getParentFile(); try { boolean onSameFileStore = FileStoreUtil.areOnSameFileStore(srcFile, parentOfTarget); return !onSameFileStore; } catch (RolloverFailure rf) { addWarn("Error while checking file store equality", rf); return false; } }
/** * Attempts tp determine whether both files are on different volumes. Returns true if we could determine that * the files are on different volumes. Returns false otherwise or if an error occurred while doing the check. * * @param srcFile * @param targetFile * @return true if on different volumes, false otherwise or if an error occurred */ Boolean areOnDifferentVolumes(File srcFile, File targetFile) throws RolloverFailure { if (!EnvUtil.isJDK7OrHigher()) { return false; } // target file is not certain to exist but its parent has to exist given the call hierarchy of this method File parentOfTarget = targetFile.getAbsoluteFile().getParentFile(); if (parentOfTarget == null) { addWarn("Parent of target file ["+targetFile+"] is null"); return null; } if (!parentOfTarget.exists()) { addWarn("Parent of target file [" + targetFile + "] does not exist"); return null; } try { boolean onSameFileStore = FileStoreUtil.areOnSameFileStore(srcFile, parentOfTarget); return !onSameFileStore; } catch (RolloverFailure rf) { addWarn("Error while checking file store equality", rf); return null; } }
boolean onSameFileStore = FileStoreUtil.areOnSameFileStore(srcFile, parentOfTarget); return !onSameFileStore; } catch (RolloverFailure rf) {
boolean onSameFileStore = FileStoreUtil.areOnSameFileStore(srcFile, parentOfTarget); return !onSameFileStore; } catch (RolloverFailure rf) {
boolean onSameFileStore = FileStoreUtil.areOnSameFileStore(srcFile, parentOfTarget); return !onSameFileStore; } catch (RolloverFailure rf) {
@Test public void filesOnSameFolderShouldBeOnTheSameFileStore() throws RolloverFailure, IOException { if(!EnvUtil.isJDK7OrHigher()) return; File parent = new File(pathPrefix); File file = new File(pathPrefix+"filesOnSameFolderShouldBeOnTheSameFileStore"); FileUtil.createMissingParentDirectories(file); file.createNewFile(); assertTrue(FileStoreUtil.areOnSameFileStore(parent, file)); }
@Ignore @Test public void manual_filesOnDifferentVolumesShouldBeDetectedAsSuch() throws RolloverFailure { if(!EnvUtil.isJDK7OrHigher()) return; // author's computer has two volumes File c = new File("c:/tmp/"); File d = new File("d:/"); assertFalse(FileStoreUtil.areOnSameFileStore(c, d)); } }