/** * Returns the file this entry links to. * * @throws IllegalStateException if the file does not exist */ public File file() { checkState(exists()); return file; }
/** * Checks that this entry exists, throwing an exception if not. * * @return this * @throws NoSuchFileException if this entry does not exist */ public DirectoryEntry requireExists(Path pathForException) throws NoSuchFileException { if (!exists()) { throw new NoSuchFileException(pathForException.toString()); } return this; }
/** * Checks that this entry does not exist, throwing an exception if it does. * * @return this * @throws FileAlreadyExistsException if this entry does not exist */ public DirectoryEntry requireDoesNotExist(Path pathForException) throws FileAlreadyExistsException { if (exists()) { throw new FileAlreadyExistsException(pathForException.toString()); } return this; }
/** * Looks up the regular file at the given path, throwing an exception if the file isn't a regular * file. Returns null if the file did not exist. */ @Nullable private RegularFile lookUpRegularFile(JimfsPath path, Set<OpenOption> options) throws IOException { store.readLock().lock(); try { DirectoryEntry entry = lookUp(path, options); if (entry.exists()) { File file = entry.file(); if (!file.isRegularFile()) { throw new FileSystemException(path.toString(), null, "not a regular file"); } return open((RegularFile) file, options); } else { return null; } } finally { store.readLock().unlock(); } }
DirectoryEntry entry = lookUp(path, Options.NOFOLLOW_LINKS); if (entry.exists()) { if (failIfExists) { throw new FileAlreadyExistsException(path.toString());
if (destEntry.exists()) { if (destEntry.file().equals(sourceFile)) { return;
/** * Returns the file this entry links to. * * @throws IllegalStateException if the file does not exist */ public File file() { checkState(exists()); return file; }
/** * Checks that this entry exists, throwing an exception if not. * * @return this * @throws NoSuchFileException if this entry does not exist */ public DirectoryEntry requireExists(Path pathForException) throws NoSuchFileException { if (!exists()) { throw new NoSuchFileException(pathForException.toString()); } return this; }
/** * Checks that this entry does not exist, throwing an exception if it does. * * @return this * @throws FileAlreadyExistsException if this entry does not exist */ public DirectoryEntry requireDoesNotExist(Path pathForException) throws FileAlreadyExistsException { if (exists()) { throw new FileAlreadyExistsException(pathForException.toString()); } return this; }
/** * Looks up the regular file at the given path, throwing an exception if the file isn't a regular * file. Returns null if the file did not exist. */ @Nullable private RegularFile lookUpRegularFile(JimfsPath path, Set<OpenOption> options) throws IOException { store.readLock().lock(); try { DirectoryEntry entry = lookUp(path, options); if (entry.exists()) { File file = entry.file(); if (!file.isRegularFile()) { throw new FileSystemException(path.toString(), null, "not a regular file"); } return open((RegularFile) file, options); } else { return null; } } finally { store.readLock().unlock(); } }
DirectoryEntry entry = lookUp(path, Options.NOFOLLOW_LINKS); if (entry.exists()) { if (failIfExists) { throw new FileAlreadyExistsException(path.toString());
if (destEntry.exists()) { if (destEntry.file().equals(sourceFile)) { return;