mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-04 05:51:19 +12:00
That should do it
This commit is contained in:
parent
b1b6a5d8c3
commit
37cfd78afd
9 changed files with 22 additions and 29 deletions
|
@ -175,7 +175,7 @@ std::error_code Account::Load()
|
||||||
|
|
||||||
std::error_code Account::Save()
|
std::error_code Account::Save()
|
||||||
{
|
{
|
||||||
fs::path path = CemuApp::GetMLCPath(fmt::format(L"usr/save/system/act/{:08x}", m_persistent_id)).ToStdWstring();
|
FSPath path = CemuApp::GetMLCPath(fmt::format(L"usr/save/system/act/{:08x}", m_persistent_id)).ToStdWstring();
|
||||||
if (!fs::exists(path))
|
if (!fs::exists(path))
|
||||||
{
|
{
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
#include "FSPath.h"
|
#include "FSPath.h"
|
||||||
|
|
||||||
|
#ifdef BOOST_OS_LINUX
|
||||||
|
|
||||||
FSPath& FSPath::operator/ (const FSPath & other)
|
FSPath& FSPath::operator/ (const FSPath & other)
|
||||||
{
|
{
|
||||||
*this /= other;
|
*this /= other;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#ifndef BOOST_OS_UNIX
|
|
||||||
FSPath& FSPath::operator/= (const FSPath & other)
|
|
||||||
{
|
|
||||||
fs::path::operator/=(other);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
FSPath& FSPath::operator/= (const FSPath & other)
|
FSPath& FSPath::operator/= (const FSPath & other)
|
||||||
{
|
{
|
||||||
// todo: implement caching.
|
// todo: implement caching.
|
||||||
|
@ -20,9 +17,9 @@ FSPath& FSPath::operator/= (const FSPath & other)
|
||||||
fs::path correctedPath = empty() ? other.root_path() : *this;
|
fs::path correctedPath = empty() ? other.root_path() : *this;
|
||||||
|
|
||||||
// helper function to convert a path's alphabet characters to lowercase.
|
// helper function to convert a path's alphabet characters to lowercase.
|
||||||
auto static lowercase_path = [](fs::path const & path)
|
auto static lowercase_path = [](FSPath const & path)
|
||||||
{
|
{
|
||||||
std::wstring string = path.wstring();
|
std::string string = path.string();
|
||||||
for (auto& i : string)
|
for (auto& i : string)
|
||||||
{
|
{
|
||||||
i = std::isalpha(i) ? std::tolower(i) : i;
|
i = std::isalpha(i) ? std::tolower(i) : i;
|
||||||
|
@ -47,19 +44,13 @@ FSPath& FSPath::operator/= (const FSPath & other)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we can't iterate directory, just copy the original case.
|
// if we can't iterate directory, just copy the original case.
|
||||||
if(listErr)
|
if(listErr || !found)
|
||||||
{
|
{
|
||||||
correctedPath /= it;
|
correctedPath /= it;
|
||||||
found = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found)
|
*this = FSPath(correctedPath);
|
||||||
*this = correctedPath;
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,9 @@ class FSPath : public fs::path {
|
||||||
FSPath() = default;
|
FSPath() = default;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
FSPath(const T & other) : fs::path(other) {};
|
FSPath(const T& other) : fs::path(other) {};
|
||||||
|
|
||||||
|
#ifdef BOOST_OS_UNIX
|
||||||
template <class T>
|
template <class T>
|
||||||
static FSPath Convert(const T& input)
|
static FSPath Convert(const T& input)
|
||||||
{
|
{
|
||||||
|
@ -15,4 +16,5 @@ class FSPath : public fs::path {
|
||||||
}
|
}
|
||||||
FSPath& operator/= (const FSPath & other);
|
FSPath& operator/= (const FSPath & other);
|
||||||
FSPath& operator/ (const FSPath & other);
|
FSPath& operator/ (const FSPath & other);
|
||||||
|
#endif
|
||||||
};
|
};
|
|
@ -219,9 +219,9 @@ FSCVirtualFile* FSCVirtualFile_Host::OpenFile(const FSPath& path, FSC_ACCESS_FLA
|
||||||
|
|
||||||
/* Device implementation */
|
/* Device implementation */
|
||||||
|
|
||||||
class fscDeviceHostFSC : public fscDeviceC {
|
class fscDeviceHostFSC : public fscDeviceC
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
FSCVirtualFile* fscDeviceOpenByPath(std::wstring_view path, FSC_ACCESS_FLAG accessFlags, void* ctx, sint32* fscStatus) override
|
FSCVirtualFile* fscDeviceOpenByPath(std::wstring_view path, FSC_ACCESS_FLAG accessFlags, void* ctx, sint32* fscStatus) override
|
||||||
{
|
{
|
||||||
*fscStatus = FSC_STATUS_OK;
|
*fscStatus = FSC_STATUS_OK;
|
||||||
|
|
|
@ -23,7 +23,7 @@ private:
|
||||||
static fs::path GetSavePath(TitleId titleId);
|
static fs::path GetSavePath(TitleId titleId);
|
||||||
|
|
||||||
TitleId m_titleId;
|
TitleId m_titleId;
|
||||||
fs::path m_path;
|
FSPath m_path;
|
||||||
bool m_isValid{false};
|
bool m_isValid{false};
|
||||||
bool m_hasMetaLoaded{false};
|
bool m_hasMetaLoaded{false};
|
||||||
ParsedMetaXml* m_parsedMetaXml{nullptr};
|
ParsedMetaXml* m_parsedMetaXml{nullptr};
|
||||||
|
|
|
@ -10,7 +10,7 @@ FileStream* FileStream::openFile(const wchar_t* path, bool allowWrite)
|
||||||
return openFile2(path, allowWrite);
|
return openFile2(path, allowWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream* FileStream::openFile2(const FSPath& path, bool allowWrite)
|
FileStream* FileStream::openFile2(const fs::path& path, bool allowWrite)
|
||||||
{
|
{
|
||||||
//return openFile(path.generic_wstring().c_str(), allowWrite);
|
//return openFile(path.generic_wstring().c_str(), allowWrite);
|
||||||
FileStream* fs = new FileStream(path, true, allowWrite);
|
FileStream* fs = new FileStream(path, true, allowWrite);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <Cafe/Filesystem/FSPath.h>
|
|
||||||
#include "Common/precompiled.h"
|
#include "Common/precompiled.h"
|
||||||
|
|
||||||
class FileStream
|
class FileStream
|
||||||
|
@ -7,7 +6,7 @@ class FileStream
|
||||||
public:
|
public:
|
||||||
static FileStream* openFile(std::string_view path);
|
static FileStream* openFile(std::string_view path);
|
||||||
static FileStream* openFile(const wchar_t* path, bool allowWrite = false);
|
static FileStream* openFile(const wchar_t* path, bool allowWrite = false);
|
||||||
static FileStream* openFile2(const FSPath& path, bool allowWrite = false);
|
static FileStream* openFile2(const fs::path& path, bool allowWrite = false);
|
||||||
|
|
||||||
static FileStream* createFile(const wchar_t* path);
|
static FileStream* createFile(const wchar_t* path);
|
||||||
static FileStream* createFile(std::string_view path);
|
static FileStream* createFile(std::string_view path);
|
||||||
|
|
|
@ -223,7 +223,7 @@ FSPath ActiveSettings::GetMlcPath()
|
||||||
FSPath ActiveSettings::GetMlcPath(std::string_view p)
|
FSPath ActiveSettings::GetMlcPath(std::string_view p)
|
||||||
{
|
{
|
||||||
std::basic_string_view<char8_t> s((const char8_t*)p.data(), p.size());
|
std::basic_string_view<char8_t> s((const char8_t*)p.data(), p.size());
|
||||||
return GetMlcPath() / FSPath(s);
|
return GetMlcPath() / s;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::path ActiveSettings::GetDefaultMLCPath()
|
fs::path ActiveSettings::GetDefaultMLCPath()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config/CemuConfig.h"
|
#include "config/CemuConfig.h"
|
||||||
|
#include "Cafe/Filesystem/FSPath.h"
|
||||||
|
|
||||||
// global active settings for fast access (reflects settings from command line and game profile)
|
// global active settings for fast access (reflects settings from command line and game profile)
|
||||||
class ActiveSettings
|
class ActiveSettings
|
||||||
|
@ -39,15 +40,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ...TArgs>
|
template <typename ...TArgs>
|
||||||
[[nodiscard]] static fs::path GetMlcPath(std::string_view format, TArgs&&... args)
|
[[nodiscard]] static FSPath GetMlcPath(std::string_view format, TArgs&&... args)
|
||||||
{
|
{
|
||||||
cemu_assert_debug(format.empty() || (format[0] != '/' && format[0] != '\\'));
|
cemu_assert_debug(format.empty() || (format[0] != '/' && format[0] != '\\'));
|
||||||
auto tmp = fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
|
auto tmp = fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
|
||||||
return GetMlcPath() / FSPath(_asUtf8(tmp));
|
return GetMlcPath() / _asUtf8(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ...TArgs>
|
template <typename ...TArgs>
|
||||||
[[nodiscard]] static fs::path GetMlcPath(std::wstring_view format, TArgs&&... args)
|
[[nodiscard]] static FSPath GetMlcPath(std::wstring_view format, TArgs&&... args)
|
||||||
{
|
{
|
||||||
cemu_assert_debug(format.empty() || (format[0] != L'/' && format[0] != L'\\'));
|
cemu_assert_debug(format.empty() || (format[0] != L'/' && format[0] != L'\\'));
|
||||||
return GetMlcPath() / fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
|
return GetMlcPath() / fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue