Matthias Andreas Benkard | b5d657a | 2022-02-03 21:14:30 +0100 | [diff] [blame^] | 1 | // SPDX-FileCopyrightText: © 2021 Matthias Andreas Benkard <code@mail.matthias.benkard.de> |
| 2 | // |
| 3 | // SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 | |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 5 | package eu.mulk.jgvariant.ostree; |
| 6 | |
| 7 | import eu.mulk.jgvariant.core.Decoder; |
| 8 | import java.nio.ByteOrder; |
| 9 | import java.util.List; |
| 10 | |
| 11 | /** |
| 12 | * Permission bits and extended attributes for a directory. |
| 13 | * |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 14 | * <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 Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 19 | * <p>Reference: {@code ostree-core.h#OSTREE_DIRMETA_GVARIANT_STRING} |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 20 | * |
| 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 Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 27 | */ |
| 28 | public 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 Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 38 | /** |
| 39 | * Acquires a {@link Decoder} for the enclosing type. |
| 40 | * |
| 41 | * @return a possibly shared {@link Decoder}. |
| 42 | */ |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 43 | public static Decoder<DirMeta> decoder() { |
| 44 | return DECODER; |
| 45 | } |
| 46 | } |