2018-01-20 04:34:48 +01:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2014-12-17 06:38:14 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-09-12 00:46:42 +02:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-05-06 07:42:43 +02:00
|
|
|
#include <array>
|
2014-09-27 21:41:21 +02:00
|
|
|
#include <cstddef>
|
2018-03-20 04:58:55 +01:00
|
|
|
#include "common/common_funcs.h"
|
2014-09-12 00:46:42 +02:00
|
|
|
#include "common/common_types.h"
|
2018-03-20 04:58:55 +01:00
|
|
|
#include "core/file_sys/filesystem.h"
|
2014-09-12 00:46:42 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// FileSys namespace
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
2018-03-20 04:58:55 +01:00
|
|
|
// Structure of a directory entry, from
|
|
|
|
// http://switchbrew.org/index.php?title=Filesystem_services#DirectoryEntry
|
|
|
|
const size_t FILENAME_LENGTH = 0x300;
|
2014-09-12 00:46:42 +02:00
|
|
|
struct Entry {
|
2018-03-20 04:58:55 +01:00
|
|
|
char filename[FILENAME_LENGTH];
|
|
|
|
INSERT_PADDING_BYTES(4);
|
|
|
|
EntryType type;
|
|
|
|
INSERT_PADDING_BYTES(3);
|
|
|
|
u64 file_size;
|
2014-09-12 00:46:42 +02:00
|
|
|
};
|
2018-03-20 04:58:55 +01: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-12 00:46:42 +02:00
|
|
|
|
2014-12-15 07:59:29 +01:00
|
|
|
class DirectoryBackend : NonCopyable {
|
2014-09-12 00:46:42 +02:00
|
|
|
public:
|
2016-09-19 03:01:46 +02:00
|
|
|
DirectoryBackend() {}
|
|
|
|
virtual ~DirectoryBackend() {}
|
2014-09-12 00:46:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List files contained in the directory
|
|
|
|
* @param count Number of entries to return at once in entries
|
|
|
|
* @param entries Buffer to read data into
|
|
|
|
* @return Number of entries listed
|
|
|
|
*/
|
2018-03-20 04:58:55 +01:00
|
|
|
virtual u64 Read(const u64 count, Entry* entries) = 0;
|
|
|
|
|
|
|
|
/// Returns the number of entries still left to read.
|
|
|
|
virtual u64 GetEntryCount() const = 0;
|
2014-09-12 00:46:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Close the directory
|
|
|
|
* @return true if the directory closed correctly
|
|
|
|
*/
|
|
|
|
virtual bool Close() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace FileSys
|