fs: Replace Mode enum by OpenMode enum
parent
0f9288e38d
commit
cc09c265e1
@ -1,39 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FileSys namespace
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
enum class EntryType : u8 {
|
||||
Directory = 0,
|
||||
File = 1,
|
||||
};
|
||||
|
||||
// Structure of a directory entry, from
|
||||
// http://switchbrew.org/index.php?title=Filesystem_services#DirectoryEntry
|
||||
struct Entry {
|
||||
Entry(std::string_view view, EntryType entry_type, u64 entry_size)
|
||||
: type{entry_type}, file_size{entry_size} {
|
||||
const std::size_t copy_size = view.copy(filename, std::size(filename) - 1);
|
||||
filename[copy_size] = '\0';
|
||||
}
|
||||
|
||||
char filename[0x301];
|
||||
INSERT_PADDING_BYTES(3);
|
||||
EntryType type;
|
||||
INSERT_PADDING_BYTES(3);
|
||||
u64 file_size;
|
||||
};
|
||||
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.");
|
||||
|
||||
} // namespace FileSys
|
@ -0,0 +1,33 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
constexpr inline size_t EntryNameLengthMax = 0x300;
|
||||
|
||||
struct DirectoryEntry {
|
||||
DirectoryEntry(std::string_view view, s8 entry_type, u64 entry_size)
|
||||
: type{entry_type}, file_size{static_cast<s64>(entry_size)} {
|
||||
const std::size_t copy_size = view.copy(name, std::size(name) - 1);
|
||||
name[copy_size] = '\0';
|
||||
}
|
||||
|
||||
char name[EntryNameLengthMax + 1];
|
||||
INSERT_PADDING_BYTES(3);
|
||||
s8 type;
|
||||
INSERT_PADDING_BYTES(3);
|
||||
s64 file_size;
|
||||
};
|
||||
|
||||
static_assert(sizeof(DirectoryEntry) == 0x310,
|
||||
"Directory Entry struct isn't exactly 0x310 bytes long!");
|
||||
static_assert(offsetof(DirectoryEntry, type) == 0x304, "Wrong offset for type in Entry.");
|
||||
static_assert(offsetof(DirectoryEntry, file_size) == 0x308, "Wrong offset for file_size in Entry.");
|
||||
|
||||
struct DirectoryHandle {
|
||||
void* handle;
|
||||
};
|
||||
|
||||
} // namespace FileSys
|
@ -0,0 +1,39 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
enum class OpenMode : u32 {
|
||||
Read = (1 << 0),
|
||||
Write = (1 << 1),
|
||||
AllowAppend = (1 << 2),
|
||||
|
||||
ReadWrite = (Read | Write),
|
||||
All = (ReadWrite | AllowAppend),
|
||||
};
|
||||
DECLARE_ENUM_FLAG_OPERATORS(OpenMode)
|
||||
|
||||
enum class OpenDirectoryMode : u64 {
|
||||
Directory = (1 << 0),
|
||||
File = (1 << 1),
|
||||
|
||||
All = (Directory | File),
|
||||
|
||||
/* TODO: Separate enum, like N? */
|
||||
_NotRequireFileSize = (1 << 31),
|
||||
};
|
||||
DECLARE_ENUM_FLAG_OPERATORS(OpenDirectoryMode)
|
||||
|
||||
enum class DirectoryEntryType : u8 {
|
||||
Directory = 0,
|
||||
File = 1,
|
||||
};
|
||||
|
||||
enum class CreateOption : u8 {
|
||||
None = (0 << 0),
|
||||
BigFile = (1 << 0),
|
||||
};
|
||||
|
||||
} // namespace FileSys
|
@ -1,23 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
enum class Mode : u32 {
|
||||
Read = 1 << 0,
|
||||
Write = 1 << 1,
|
||||
ReadWrite = Read | Write,
|
||||
Append = 1 << 2,
|
||||
ReadAppend = Read | Append,
|
||||
WriteAppend = Write | Append,
|
||||
All = ReadWrite | Append,
|
||||
};
|
||||
|
||||
DECLARE_ENUM_FLAG_OPERATORS(Mode)
|
||||
|
||||
} // namespace FileSys
|
Loading…
Reference in New Issue