|
|
|
|
@ -36,22 +36,22 @@ namespace {
|
|
|
|
|
// Validates that a Type is of a particular size and that its alignment is <= the size of the type.
|
|
|
|
|
// Done with templates so that error messages include actual size.
|
|
|
|
|
template <std::size_t A, std::size_t B> |
|
|
|
|
struct assert_eq : std::true_type { |
|
|
|
|
struct AssertEq : std::true_type { |
|
|
|
|
static_assert(A == B, "A == B not satisfied"); |
|
|
|
|
}; |
|
|
|
|
template <std::size_t A, std::size_t B> |
|
|
|
|
struct assert_lte : std::true_type { |
|
|
|
|
struct AssertLte : std::true_type { |
|
|
|
|
static_assert(A <= B, "A <= B not satisfied"); |
|
|
|
|
}; |
|
|
|
|
template <typename T, std::size_t S> |
|
|
|
|
struct check_size : assert_eq<sizeof(T), S>, assert_lte<alignof(T), sizeof(T)> { |
|
|
|
|
struct CheckSize : AssertEq<sizeof(T), S>, AssertLte<alignof(T), sizeof(T)> { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Check sizes and alignments of the structs that we decrypt and encrypt.
|
|
|
|
|
// The decryption algorithm treats them as a stream of 32-bit uints, so the
|
|
|
|
|
// sizes must be exact as there cannot be any padding.
|
|
|
|
|
static_assert(check_size<_HASHENTRY, 4 * 4>::value, "sizeof(_HASHENTRY) == 4 * 4 && alignof(_HASHENTRY) <= 4 * 4 not satisfied"); |
|
|
|
|
static_assert(check_size<_BLOCKENTRY, 4 * 4>::value, "sizeof(_BLOCKENTRY) == 4 * 4 && alignof(_BLOCKENTRY) <= 4 * 4 not satisfied"); |
|
|
|
|
static_assert(CheckSize<_HASHENTRY, 4 * 4>::value, "sizeof(_HASHENTRY) == 4 * 4 && alignof(_HASHENTRY) <= 4 * 4 not satisfied"); |
|
|
|
|
static_assert(CheckSize<_BLOCKENTRY, 4 * 4>::value, "sizeof(_BLOCKENTRY) == 4 * 4 && alignof(_BLOCKENTRY) <= 4 * 4 not satisfied"); |
|
|
|
|
|
|
|
|
|
const char *DirToString(std::ios::seekdir dir) |
|
|
|
|
{ |
|
|
|
|
|