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 file. |
| 13 | * |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 14 | * <p>Stored in a POSIX extended attribute on the corresponding {@link ObjectType#FILE} object in |
| 15 | * repositories in “bare-user” format. |
| 16 | * |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 17 | * <p>Reference: {@code ostree-core.h#OSTREE_FILEMETA_GVARIANT_STRING} |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 18 | * |
| 19 | * @param uid the user ID that owns the file. |
| 20 | * @param gid the group ID that owns the file. |
| 21 | * @param mode the POSIX permission bits. |
| 22 | * @param xattrs POSIX extended attributes. |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 23 | */ |
| 24 | public record FileMeta(int uid, int gid, int mode, List<Xattr> xattrs) { |
| 25 | |
| 26 | private static final Decoder<FileMeta> DECODER = |
| 27 | Decoder.ofStructure( |
| 28 | FileMeta.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<FileMeta> decoder() { |
| 40 | return DECODER; |
| 41 | } |
| 42 | } |