blob: 2786ce9fc4c659299d0830c859b0e797df260ab0 [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 file.
9 *
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010010 * <p>Stored in a POSIX extended attribute on the corresponding {@link ObjectType#FILE} object in
11 * repositories in “bare-user” format.
12 *
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010013 * <p>Reference: {@code ostree-core.h#OSTREE_FILEMETA_GVARIANT_STRING}
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010014 *
15 * @param uid the user ID that owns the file.
16 * @param gid the group ID that owns the file.
17 * @param mode the POSIX permission bits.
18 * @param xattrs POSIX extended attributes.
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010019 */
20public record FileMeta(int uid, int gid, int mode, List<Xattr> xattrs) {
21
22 private static final Decoder<FileMeta> DECODER =
23 Decoder.ofStructure(
24 FileMeta.class,
25 Decoder.ofInt().withByteOrder(ByteOrder.BIG_ENDIAN),
26 Decoder.ofInt().withByteOrder(ByteOrder.BIG_ENDIAN),
27 Decoder.ofInt().withByteOrder(ByteOrder.BIG_ENDIAN),
28 Decoder.ofArray(Xattr.decoder()));
29
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010030 /**
31 * Acquires a {@link Decoder} for the enclosing type.
32 *
33 * @return a possibly shared {@link Decoder}.
34 */
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010035 public static Decoder<FileMeta> decoder() {
36 return DECODER;
37 }
38}