@Override public boolean exists() { return base.exists(); }
/** * Checks if a file exists. * This method is similar to Java 7 <code>java.nio.file.Path.exists</code>. * * @param fileName the file name * @return true if it exists */ public static boolean exists(String fileName) { return FilePath.get(fileName).exists(); }
@Override public long lastModified() { long lastModified = 0; for (int i = 0;; i++) { FilePath f = getBase(i); if (f.exists()) { long l = f.lastModified(); lastModified = Math.max(lastModified, l); } else { break; } } return lastModified; }
@Override public void delete() { for (int i = 0;; i++) { FilePath f = getBase(i); if (f.exists()) { f.delete(); } else { break; } } }
@Override public boolean setReadOnly() { boolean result = false; for (int i = 0;; i++) { FilePath f = getBase(i); if (f.exists()) { result = f.setReadOnly(); } else { break; } } return result; }
@Override public long size() { long length = 0; for (int i = 0;; i++) { FilePath f = getBase(i); if (f.exists()) { length += f.size(); } else { break; } } return length; }
@Override public void moveTo(FilePath path, boolean atomicReplace) { FilePathSplit newName = (FilePathSplit) path; for (int i = 0;; i++) { FilePath o = getBase(i); if (o.exists()) { o.moveTo(newName.getBase(i), atomicReplace); } else { break; } } }
@Override public InputStream newInputStream() throws IOException { InputStream input = getBase().newInputStream(); for (int i = 1;; i++) { FilePath f = getBase(i); if (f.exists()) { InputStream i2 = f.newInputStream(); input = new SequenceInputStream(input, i2); } else { break; } } return input; }
for (int i = 1;; i++) { FilePath f = getBase(i); if (f.exists()) { list.add(f.open(mode)); } else {
/** * Create a new temporary file. * * @param suffix the suffix * @param deleteOnExit if the file should be deleted when the virtual * machine exists * @param inTempDir if the file should be stored in the temporary directory * @return the name of the created file */ public FilePath createTempFile(String suffix, boolean deleteOnExit, boolean inTempDir) throws IOException { while (true) { FilePath p = getPath(name + getNextTempFileNamePart(false) + suffix); if (p.exists() || !p.createFile()) { // in theory, the random number could collide getNextTempFileNamePart(true); continue; } p.open("rw").close(); return p; } }