Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 1 | package eu.mulk.jgvariant.ostree; |
| 2 | |
| 3 | import eu.mulk.jgvariant.core.Decoder; |
| 4 | import java.nio.ByteOrder; |
| 5 | import java.util.List; |
| 6 | |
| 7 | /** |
| 8 | * Permission bits and extended attributes for a directory. |
| 9 | * |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame^] | 10 | * <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 Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 15 | * <p>Reference: {@code ostree-core.h#OSTREE_DIRMETA_GVARIANT_STRING} |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame^] | 16 | * |
| 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 Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 23 | */ |
| 24 | public 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 Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame^] | 34 | /** |
| 35 | * Acquires a {@link Decoder} for the enclosing type. |
| 36 | * |
| 37 | * @return a possibly shared {@link Decoder}. |
| 38 | */ |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 39 | public static Decoder<DirMeta> decoder() { |
| 40 | return DECODER; |
| 41 | } |
| 42 | } |