blob: 1a9230f1436b7bd862b2cb07f66a163daa7e3c6c [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 directory.
13 *
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010014 * <p>Often comes in a pair with {@link DirTree}.
15 *
16 * <p>Referenced by {@link Commit#rootDirMetaChecksum()} and {@link
17 * DirTree.Directory#dirChecksum()}.
18 *
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010019 * <p>Reference: {@code ostree-core.h#OSTREE_DIRMETA_GVARIANT_STRING}
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010020 *
21 * @param uid the user ID that owns the directory.
22 * @param gid the group ID that owns the directory.
23 * @param mode the POSIX permission bits.
24 * @param xattrs POSIX extended attributes.
25 * @see DirTree
26 * @see ObjectType#DIR_META
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010027 */
28public record DirMeta(int uid, int gid, int mode, List<Xattr> xattrs) {
29
30 private static final Decoder<DirMeta> DECODER =
31 Decoder.ofStructure(
32 DirMeta.class,
33 Decoder.ofInt().withByteOrder(ByteOrder.BIG_ENDIAN),
34 Decoder.ofInt().withByteOrder(ByteOrder.BIG_ENDIAN),
35 Decoder.ofInt().withByteOrder(ByteOrder.BIG_ENDIAN),
36 Decoder.ofArray(Xattr.decoder()));
37
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010038 /**
39 * Acquires a {@link Decoder} for the enclosing type.
40 *
41 * @return a possibly shared {@link Decoder}.
42 */
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010043 public static Decoder<DirMeta> decoder() {
44 return DECODER;
45 }
46}