3
0
Fork 0
forked from suyu/suyu

Merge pull request #4476 from lioncash/tz

time_zone_binary: Make use of designated initializers
This commit is contained in:
bunnei 2020-08-04 18:56:28 -04:00 committed by GitHub
commit 142930e609
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,9 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <array>
#include <vector>
#include "common/swap.h" #include "common/swap.h"
#include "core/file_sys/system_archive/time_zone_binary.h" #include "core/file_sys/system_archive/time_zone_binary.h"
#include "core/file_sys/vfs_vector.h" #include "core/file_sys/vfs_vector.h"
@ -615,31 +618,36 @@ static constexpr std::array<u8, 9633> LOCATION_NAMES{
0x0a}; 0x0a};
static VirtualFile GenerateDefaultTimeZoneFile() { static VirtualFile GenerateDefaultTimeZoneFile() {
struct { struct TimeZoneInfo {
s64_be at; s64_be at;
INSERT_PADDING_BYTES(7); std::array<u8, 7> padding1;
std::array<char, 4> time_zone_chars; std::array<char, 4> time_zone_chars;
INSERT_PADDING_BYTES(2); std::array<u8, 2> padding2;
std::array<char, 6> time_zone_name; std::array<char, 6> time_zone_name;
} time_zone_info{}; };
const VirtualFile file{std::make_shared<VectorVfsFile>( VirtualFile file{std::make_shared<VectorVfsFile>(
std::vector<u8>(sizeof(Service::Time::TimeZone::TzifHeader) + sizeof(time_zone_info)), std::vector<u8>(sizeof(Service::Time::TimeZone::TzifHeader) + sizeof(TimeZoneInfo)),
"GMT")}; "GMT")};
Service::Time::TimeZone::TzifHeader header{}; const Service::Time::TimeZone::TzifHeader header{
header.magic = 0x545a6966; .magic = 0x545a6966,
header.version = 0x32; .version = 0x32,
header.ttis_gmt_count = 0x1; .ttis_gmt_count = 1,
header.ttis_std_count = 0x1; .ttis_std_count = 1,
header.time_count = 0x1; .time_count = 1,
header.type_count = 0x1; .type_count = 1,
header.char_count = 0x4; .char_count = 4,
};
file->WriteObject(header, 0); file->WriteObject(header, 0);
time_zone_info.at = 0xf8; const TimeZoneInfo time_zone_info{
time_zone_info.time_zone_chars = {'G', 'M', 'T', '\0'}; .at = 0xf8,
time_zone_info.time_zone_name = {'\n', 'G', 'M', 'T', '0', '\n'}; .padding1 = {},
.time_zone_chars = {'G', 'M', 'T', '\0'},
.padding2 = {},
.time_zone_name = {'\n', 'G', 'M', 'T', '0', '\n'},
};
file->WriteObject(time_zone_info, sizeof(Service::Time::TimeZone::TzifHeader)); file->WriteObject(time_zone_info, sizeof(Service::Time::TimeZone::TzifHeader));
return file; return file;