mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Merge pull request #6421 from leoetlino/fs-interface
IOS: Refactor the filesystem code
This commit is contained in:
@ -138,6 +138,7 @@
|
||||
<ClInclude Include="PcapFile.h" />
|
||||
<ClInclude Include="Profiler.h" />
|
||||
<ClInclude Include="QoSSession.h" />
|
||||
<ClInclude Include="Result.h" />
|
||||
<ClInclude Include="ScopeGuard.h" />
|
||||
<ClInclude Include="SDCardUtil.h" />
|
||||
<ClInclude Include="Semaphore.h" />
|
||||
|
@ -59,6 +59,7 @@
|
||||
<ClInclude Include="PcapFile.h" />
|
||||
<ClInclude Include="Profiler.h" />
|
||||
<ClInclude Include="QoSSession.h" />
|
||||
<ClInclude Include="Result.h" />
|
||||
<ClInclude Include="ScopeGuard.h" />
|
||||
<ClInclude Include="SDCardUtil.h" />
|
||||
<ClInclude Include="SettingsHandler.h" />
|
||||
|
@ -31,7 +31,7 @@ enum LOG_TYPE
|
||||
IOS,
|
||||
IOS_DI,
|
||||
IOS_ES,
|
||||
IOS_FILEIO,
|
||||
IOS_FS,
|
||||
IOS_NET,
|
||||
IOS_SD,
|
||||
IOS_SSL,
|
||||
|
@ -99,7 +99,7 @@ LogManager::LogManager()
|
||||
m_log[LogTypes::IOS] = {"IOS", "IOS"};
|
||||
m_log[LogTypes::IOS_DI] = {"IOS_DI", "IOS - Drive Interface"};
|
||||
m_log[LogTypes::IOS_ES] = {"IOS_ES", "IOS - ETicket Services"};
|
||||
m_log[LogTypes::IOS_FILEIO] = {"IOS_FILEIO", "IOS - FileIO"};
|
||||
m_log[LogTypes::IOS_FS] = {"IOS_FS", "IOS - Filesystem Services"};
|
||||
m_log[LogTypes::IOS_SD] = {"IOS_SD", "IOS - SDIO"};
|
||||
m_log[LogTypes::IOS_SSL] = {"IOS_SSL", "IOS - SSL"};
|
||||
m_log[LogTypes::IOS_STM] = {"IOS_STM", "IOS - State Transition Manager"};
|
||||
|
30
Source/Core/Common/Result.h
Normal file
30
Source/Core/Common/Result.h
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2018 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace Common
|
||||
{
|
||||
template <typename ResultCode, typename T>
|
||||
class Result final
|
||||
{
|
||||
public:
|
||||
Result(ResultCode code) : m_variant{code} {}
|
||||
Result(const T& t) : m_variant{t} {}
|
||||
Result(T&& t) : m_variant{std::move(t)} {}
|
||||
explicit operator bool() const { return Succeeded(); }
|
||||
bool Succeeded() const { return std::holds_alternative<T>(m_variant); }
|
||||
// Must only be called when Succeeded() returns false.
|
||||
ResultCode Error() const { return std::get<ResultCode>(m_variant); }
|
||||
// Must only be called when Succeeded() returns true.
|
||||
const T& operator*() const { return std::get<T>(m_variant); }
|
||||
const T* operator->() const { return &std::get<T>(m_variant); }
|
||||
T& operator*() { return std::get<T>(m_variant); }
|
||||
T* operator->() { return &std::get<T>(m_variant); }
|
||||
private:
|
||||
std::variant<ResultCode, T> m_variant;
|
||||
};
|
||||
} // namespace Common
|
@ -166,4 +166,16 @@ inline T FromBigEndian(T data)
|
||||
swap<sizeof(data)>(reinterpret_cast<u8*>(&data));
|
||||
return data;
|
||||
}
|
||||
|
||||
template <typename value_type>
|
||||
struct BigEndianValue
|
||||
{
|
||||
static_assert(std::is_arithmetic<value_type>(), "value_type must be an arithmetic type");
|
||||
BigEndianValue() = default;
|
||||
explicit BigEndianValue(value_type val) { *this = val; }
|
||||
operator value_type() const { return FromBigEndian(raw); }
|
||||
void operator=(value_type v) { raw = FromBigEndian(v); }
|
||||
private:
|
||||
value_type raw;
|
||||
};
|
||||
} // Namespace Common
|
||||
|
Reference in New Issue
Block a user