2022-04-23 01:59:50 -07:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-09-11 15:46:42 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-09-27 12:41:21 -07:00
|
|
|
#include <cstddef>
|
2018-03-19 20:58:55 -07:00
|
|
|
#include "common/common_funcs.h"
|
2014-09-11 15:46:42 -07:00
|
|
|
#include "common/common_types.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// FileSys namespace
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
2019-11-27 02:07:08 -08:00
|
|
|
enum class EntryType : u8 {
|
2018-07-18 18:07:11 -07:00
|
|
|
Directory = 0,
|
|
|
|
File = 1,
|
|
|
|
};
|
|
|
|
|
2018-03-19 20:58:55 -07:00
|
|
|
// Structure of a directory entry, from
|
|
|
|
// http://switchbrew.org/index.php?title=Filesystem_services#DirectoryEntry
|
2014-09-11 15:46:42 -07:00
|
|
|
struct Entry {
|
2018-08-08 14:49:57 -07:00
|
|
|
Entry(std::string_view view, EntryType entry_type, u64 entry_size)
|
|
|
|
: type{entry_type}, file_size{entry_size} {
|
2018-09-15 06:21:06 -07:00
|
|
|
const std::size_t copy_size = view.copy(filename, std::size(filename) - 1);
|
2018-08-08 14:49:57 -07:00
|
|
|
filename[copy_size] = '\0';
|
|
|
|
}
|
|
|
|
|
2018-12-02 20:15:55 -08:00
|
|
|
char filename[0x301];
|
|
|
|
INSERT_PADDING_BYTES(3);
|
2018-03-19 20:58:55 -07:00
|
|
|
EntryType type;
|
|
|
|
INSERT_PADDING_BYTES(3);
|
|
|
|
u64 file_size;
|
2014-09-11 15:46:42 -07:00
|
|
|
};
|
2018-03-19 20:58:55 -07:00
|
|
|
static_assert(sizeof(Entry) == 0x310, "Directory Entry struct isn't exactly 0x310 bytes long!");
|
|
|
|
static_assert(offsetof(Entry, type) == 0x304, "Wrong offset for type in Entry.");
|
|
|
|
static_assert(offsetof(Entry, file_size) == 0x308, "Wrong offset for file_size in Entry.");
|
2014-09-11 15:46:42 -07:00
|
|
|
|
|
|
|
} // namespace FileSys
|