Пример #1
0
  @Override
  public boolean setReadOnly(File f) {
    // Test for existence.
    if (!VMFile.exists(f.getPath())) return false;

    return VMFile.setReadOnly(f.getPath());
  }
Пример #2
0
  @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;
  }
Пример #3
0
 @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;
 }
Пример #4
0
  @Override
  public String[] list(File f) {
    if (!f.exists() || !f.isDirectory()) return null;

    // Get the list of files
    return VMFile.list(f.getPath());
  }
Пример #5
0
 @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;
 }
Пример #6
0
  @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;
  }
Пример #7
0
 @Override
 public boolean delete(File f) {
   return VMFile.delete(f.getPath());
 }
Пример #8
0
 /**
  * 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);
 }
Пример #9
0
 @Override
 public boolean createDirectory(File f) {
   return VMFile.mkdir(f.getPath());
 }
Пример #10
0
 @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);
 }
Пример #11
0
 @Override
 public boolean setLastModifiedTime(File f, long time) {
   return VMFile.setLastModified(f.getPath(), time);
 }
Пример #12
0
 @Override
 public boolean rename(File f1, File f2) {
   return VMFile.renameTo(f1.getPath(), f2.getPath());
 }
Пример #13
0
 @Override
 public File[] listRoots() {
   return VMFile.listRoots();
 }
Пример #14
0
 @Override
 public long getLength(File f) {
   return VMFile.length(f.getPath());
 }
Пример #15
0
 @Override
 public long getLastModifiedTime(File f) {
   return VMFile.lastModified(f.getPath());
 }