コード例 #1
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;
  }