blob: 35c5212718f650ec2c7a1e71235ab40de9be4937 [file] [log] [blame]
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +01001package eu.mulk.jgvariant.ostree;
2
3import eu.mulk.jgvariant.core.Decoder;
4import java.nio.ByteOrder;
5import java.util.List;
6
7/**
8 * Permission bits and extended attributes for a directory.
9 *
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010010 * <p>Often comes in a pair with {@link DirTree}.
11 *
12 * <p>Referenced by {@link Commit#rootDirMetaChecksum()} and {@link
13 * DirTree.Directory#dirChecksum()}.
14 *
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010015 * <p>Reference: {@code ostree-core.h#OSTREE_DIRMETA_GVARIANT_STRING}
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010016 *
17 * @param uid the user ID that owns the directory.
18 * @param gid the group ID that owns the directory.
19 * @param mode the POSIX permission bits.
20 * @param xattrs POSIX extended attributes.
21 * @see DirTree
22 * @see ObjectType#DIR_META
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010023 */
24public record DirMeta(int uid, int gid, int mode, List<Xattr> xattrs) {
25
26 private static final Decoder<DirMeta> DECODER =
27 Decoder.ofStructure(
28 DirMeta.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<DirMeta> decoder() {
40 return DECODER;
41 }
42}