blob: bf292fd36b5fbcfe08b3a0fff9bb5400706a07bb [file] [log] [blame]
Matthias Andreas Benkardb5d657a2022-02-03 21:14:30 +01001// SPDX-FileCopyrightText: © 2021 Matthias Andreas Benkard <code@mail.matthias.benkard.de>
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +01005package eu.mulk.jgvariant.ostree;
6
7import eu.mulk.jgvariant.core.Decoder;
8import java.nio.ByteOrder;
9import java.util.List;
10
11/**
12 * Permission bits and extended attributes for a file.
13 *
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010014 * <p>Stored in a POSIX extended attribute on the corresponding {@link ObjectType#FILE} object in
15 * repositories in “bare-user” format.
16 *
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010017 * <p>Reference: {@code ostree-core.h#OSTREE_FILEMETA_GVARIANT_STRING}
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010018 *
19 * @param uid the user ID that owns the file.
20 * @param gid the group ID that owns the file.
21 * @param mode the POSIX permission bits.
22 * @param xattrs POSIX extended attributes.
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010023 */
24public record FileMeta(int uid, int gid, int mode, List<Xattr> xattrs) {
25
26 private static final Decoder<FileMeta> DECODER =
27 Decoder.ofStructure(
28 FileMeta.class,
29 Decoder.ofInt().withByteOrder(ByteOrder.BIG_ENDIAN),
30 Decoder.ofInt().withByteOrder(ByteOrder.BIG_ENDIAN),
31 Decoder.ofInt().withByteOrder(ByteOrder.BIG_ENDIAN),
32 Decoder.ofArray(Xattr.decoder()));
33
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010034 /**
35 * Acquires a {@link Decoder} for the enclosing type.
36 *
37 * @return a possibly shared {@link Decoder}.
38 */
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010039 public static Decoder<FileMeta> decoder() {
40 return DECODER;
41 }
42}