예제 #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());
 }