2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-18 01:08:10 +02:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 23:09:55 -04:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-21 01:47:53 +01:00
|
|
|
#include <cstddef>
|
2017-06-04 10:33:14 +02:00
|
|
|
#include <optional>
|
2014-02-21 01:47:53 +01:00
|
|
|
#include <string>
|
2008-12-08 04:46:09 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2014-02-21 01:47:53 +01:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "DiscIO/Filesystem.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
namespace DiscIO
|
|
|
|
{
|
2017-06-06 11:49:01 +02:00
|
|
|
class Volume;
|
2015-06-13 12:51:24 +02:00
|
|
|
struct Partition;
|
2014-02-21 01:47:53 +01:00
|
|
|
|
2015-07-28 16:56:25 +02:00
|
|
|
class FileInfoGCWii : public FileInfo
|
|
|
|
{
|
|
|
|
public:
|
2015-07-29 16:42:29 +02:00
|
|
|
FileInfoGCWii(u64 name_offset, u64 offset, u64 file_size, std::string name);
|
2015-07-28 16:56:25 +02:00
|
|
|
~FileInfoGCWii() override;
|
|
|
|
|
|
|
|
u64 GetOffset() const override { return m_Offset; }
|
|
|
|
u64 GetSize() const override { return m_FileSize; }
|
|
|
|
bool IsDirectory() const override { return (m_NameOffset & 0xFF000000) != 0; }
|
2015-07-29 16:42:29 +02:00
|
|
|
const std::string& GetName() const override { return m_Name; }
|
2015-07-28 16:56:25 +02:00
|
|
|
// TODO: These shouldn't be public
|
2015-07-29 16:42:29 +02:00
|
|
|
std::string m_Name;
|
2015-07-28 16:56:25 +02:00
|
|
|
const u64 m_NameOffset = 0u;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const u64 m_Offset = 0u;
|
|
|
|
const u64 m_FileSize = 0u;
|
|
|
|
};
|
|
|
|
|
2017-06-06 11:49:01 +02:00
|
|
|
class FileSystemGCWii : public FileSystem
|
2008-12-08 04:46:09 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-06-06 11:49:01 +02:00
|
|
|
FileSystemGCWii(const Volume* _rVolume, const Partition& partition);
|
2015-07-28 16:56:25 +02:00
|
|
|
~FileSystemGCWii() override;
|
2016-06-24 10:43:46 +02:00
|
|
|
bool IsValid() const override { return m_Valid; }
|
|
|
|
u64 GetFileSize(const std::string& _rFullPath) override;
|
2015-07-28 16:56:25 +02:00
|
|
|
const std::vector<FileInfoGCWii>& GetFileList() override;
|
2015-07-29 16:42:29 +02:00
|
|
|
std::string GetPath(u64 _Address) override;
|
|
|
|
std::string GetPathFromFSTOffset(size_t file_info_offset) override;
|
2016-06-24 10:43:46 +02:00
|
|
|
u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _MaxBufferSize,
|
|
|
|
u64 _OffsetInFile) override;
|
|
|
|
bool ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename) override;
|
|
|
|
bool ExportApploader(const std::string& _rExportFolder) const override;
|
|
|
|
bool ExportDOL(const std::string& _rExportFolder) const override;
|
2017-06-04 10:33:14 +02:00
|
|
|
std::optional<u64> GetBootDOLOffset() const override;
|
|
|
|
std::optional<u32> GetBootDOLSize(u64 dol_offset) const override;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-07-03 03:26:23 +00:00
|
|
|
private:
|
2016-06-24 10:43:46 +02:00
|
|
|
bool m_Initialized;
|
|
|
|
bool m_Valid;
|
2015-06-13 20:50:03 +02:00
|
|
|
u32 m_offset_shift;
|
2015-07-28 16:56:25 +02:00
|
|
|
std::vector<FileInfoGCWii> m_FileInfoVector;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
|
|
|
std::string GetStringFromOffset(u64 _Offset) const;
|
2015-07-28 16:56:25 +02:00
|
|
|
const FileInfoGCWii* FindFileInfo(const std::string& _rFullPath);
|
2016-06-24 10:43:46 +02:00
|
|
|
bool DetectFileSystem();
|
|
|
|
void InitFileSystem();
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
2016-06-24 10:43:46 +02:00
|
|
|
} // namespace
|