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 file. |
| 9 | * |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame^] | 10 | * <p>Stored in a POSIX extended attribute on the corresponding {@link ObjectType#FILE} object in |
| 11 | * repositories in “bare-user” format. |
| 12 | * |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 13 | * <p>Reference: {@code ostree-core.h#OSTREE_FILEMETA_GVARIANT_STRING} |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame^] | 14 | * |
| 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 Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 19 | */ |
| 20 | public 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 Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame^] | 30 | /** |
| 31 | * Acquires a {@link Decoder} for the enclosing type. |
| 32 | * |
| 33 | * @return a possibly shared {@link Decoder}. |
| 34 | */ |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 35 | public static Decoder<FileMeta> decoder() { |
| 36 | return DECODER; |
| 37 | } |
| 38 | } |