コード例 #1
0
  /**
   * That method ought to be called before any DirectDiskAccess operation is performed by the node
   *
   * @param filename
   * @param writeRequest : Are willing to write or to read ?
   * @return boolean : allowed or not
   */
  protected boolean allowDDAFrom(File filename, boolean writeRequest) {
    String parentDirectory = FileUtil.getCanonicalFile(filename).getParent();
    DirectoryAccess da = null;

    synchronized (checkedDirectories) {
      da = checkedDirectories.get(parentDirectory);
    }

    if (logMINOR) Logger.minor(this, "Checking DDA: " + da + " for " + parentDirectory);

    if (writeRequest) return (da == null ? server.isDownloadDDAAlwaysAllowed() : da.canWrite);
    else return (da == null ? server.isUploadDDAAlwaysAllowed() : da.canRead);
  }