LongFileAttributeAccessor (@NotNull FSRecordsImpl vfs, @NotNull FileAttribute attribute) { if (!attribute.isFixedSize()) { throw new IllegalArgumentException(attribute + " must be fixedSize"); } return new LongFileAttributeAccessor() { @Override public long read(int fileId, long defaultValue) throws IOException { Long value = vfs.readAttributeRaw(fileId, attribute, buffer -> { //stream.writeLong() writes in BIG_ENDIAN (default byte order for JVM) return buffer.order(BIG_ENDIAN).getLong(); }); return value == null ? defaultValue : value.longValue(); } @Override public void write(int fileId, long value) throws IOException { try (var stream = vfs.writeAttribute(fileId, attribute)) { stream.writeLong(value); } //vfs.writeAttributeRaw(fileId, attribute, buffer -> { // return buffer.putLong(value); //}); } @Override public void update(int fileId, @NotNull LongUnaryOperator updater) throws IOException { throw new UnsupportedOperationException("Method is not implemented"); } }; }