@Override public boolean setReadOnly(File f) { // Test for existence. if (!VMFile.exists(f.getPath())) return false; return VMFile.setReadOnly(f.getPath()); }
@Override public int getBooleanAttributes(File f) { int attributes = 0; attributes |= (VMFile.exists(f.getPath()) ? BA_EXISTS : 0); attributes |= (VMFile.isFile(f.getPath()) ? BA_REGULAR : 0); attributes |= (VMFile.isDirectory(f.getPath()) ? BA_DIRECTORY : 0); attributes |= (VMFile.isHidden(f.getPath()) ? BA_HIDDEN : 0); return attributes; }
@Override public boolean setPermission(File f, int access, boolean enable, boolean owneronly) { boolean success = false; switch (access) { case ACCESS_READ: success = VMFile.setReadable(f.getPath(), enable, owneronly); break; case ACCESS_WRITE: success = VMFile.setWritable(f.getPath(), enable, owneronly); break; case ACCESS_EXECUTE: success = VMFile.setExecutable(f.getPath(), enable, owneronly); break; } return success; }
@Override public String[] list(File f) { if (!f.exists() || !f.isDirectory()) return null; // Get the list of files return VMFile.list(f.getPath()); }
@Override public long getSpace(File f, int t) { long space = 0L; switch (t) { case SPACE_TOTAL: space = VMFile.getTotalSpace(f.getPath()); break; // TODO case SPACE_FREE: space = VMFile.getFreeSpace(f.getPath()); break; // TODO case SPACE_USABLE: space = VMFile.getUsableSpace(f.getPath()); break; // TODO } return space; }
@Override public boolean checkAccess(File f, int access) { boolean canAccess; if (!VMFile.exists(f.getPath())) return false; switch (access) { case ACCESS_READ: canAccess = VMFile.canRead(f.getPath()); break; case ACCESS_WRITE: if (VMFile.isDirectory(f.getPath())) canAccess = VMFile.canWriteDirectory(f); else canAccess = VMFile.canWrite(f.getPath()); break; case ACCESS_EXECUTE: canAccess = VMFile.canExecute(f.getPath()); break; default: throw new IllegalArgumentException("invalid access : " + access); } return canAccess; }
@Override public boolean delete(File f) { return VMFile.delete(f.getPath()); }
/** * The resulting temporary file may have more restrictive access permission on some platforms, if * restrictive is true. */ @Override public boolean createFileExclusively(String pathname, boolean restrictive) throws IOException { return VMFile.create(pathname); }
@Override public boolean createDirectory(File f) { return VMFile.mkdir(f.getPath()); }
@Override public String canonicalize(String path) throws IOException { // note : we expect that the File class from OpenJDK give an absolute path return VMFile.toCanonicalForm(path); }
@Override public boolean setLastModifiedTime(File f, long time) { return VMFile.setLastModified(f.getPath(), time); }
@Override public boolean rename(File f1, File f2) { return VMFile.renameTo(f1.getPath(), f2.getPath()); }
@Override public File[] listRoots() { return VMFile.listRoots(); }
@Override public long getLength(File f) { return VMFile.length(f.getPath()); }
@Override public long getLastModifiedTime(File f) { return VMFile.lastModified(f.getPath()); }