code: private static RegularFile open(RegularFile file, Set<OpenOption> options) {
      if (options.contains(TRUNCATE_EXISTING) && options.contains(WRITE)) {
        file.writeLock().lock();
        try {
          file.truncate(0);
        } finally {
          file.writeLock().unlock();
        }
      }
  
      // must be opened while holding a file store lock to ensure no race between opening and
      // deleting the file
      file.opened();
  
      return file;
    }
docs: Opens the given regular file with the given options, truncating it if necessary and
  incrementing its open count. Returns the given file.