GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/util/uuid.h
Date: 2025-07-27 02:42:09
Exec Total Coverage
Lines: 4 4 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #ifndef CVMFS_UTIL_UUID_H_
6 #define CVMFS_UTIL_UUID_H_
7
8 #include <inttypes.h>
9 #include <uuid/uuid.h>
10
11 #include <cstdint>
12 #include <string>
13
14 #include "util/export.h"
15
16 namespace cvmfs {
17
18 /**
19 * Holds a unique identifies which is either read from a file or, if the file
20 * does not yet exist, created and stored in a file. This is how it is used to
21 * identify a cvmfs cache directory.
22 *
23 * In order to create many UUIDs for short-lived objects, use the CreateOneTime
24 * factory method.
25 */
26 class CVMFS_EXPORT Uuid {
27 public:
28 static Uuid *Create(const std::string &store_path);
29 static std::string CreateOneTime();
30 1340 std::string uuid() const { return uuid_; }
31 500168 const unsigned char *data() const {
32 500168 return reinterpret_cast<const unsigned char *>(&uuid_presentation_.uuid);
33 }
34 500168 unsigned size() const { return sizeof(uuid_presentation_.uuid); }
35
36 private:
37 void MkUuid();
38 Uuid();
39
40 std::string uuid_;
41 union {
42 uuid_t uuid;
43 struct __attribute__((__packed__)) {
44 uint32_t a;
45 uint16_t b;
46 uint16_t c;
47 uint16_t d;
48 uint32_t e1;
49 uint16_t e2;
50 } split;
51 } uuid_presentation_;
52 };
53
54 } // namespace cvmfs
55
56 #endif // CVMFS_UTIL_UUID_H_
57