libstrat: namespace hossynch.hpp

This commit is contained in:
Michael Scire
2019-09-24 03:15:36 -07:00
committed by SciresM
parent 73d904036d
commit bb223eb5ae
57 changed files with 923 additions and 773 deletions

View File

@@ -145,7 +145,7 @@ Result DirectorySaveDataFileSystem::GetFullPath(char *out, size_t out_size, cons
}
void DirectorySaveDataFileSystem::OnWritableFileClose() {
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
this->open_writable_files--;
/* TODO: Abort if < 0? N does not. */
@@ -171,7 +171,7 @@ Result DirectorySaveDataFileSystem::CreateFileImpl(const FsPath &path, uint64_t
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->CreateFile(full_path, size, flags);
}
@@ -179,7 +179,7 @@ Result DirectorySaveDataFileSystem::DeleteFileImpl(const FsPath &path) {
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->DeleteFile(full_path);
}
@@ -187,7 +187,7 @@ Result DirectorySaveDataFileSystem::CreateDirectoryImpl(const FsPath &path) {
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->CreateDirectory(full_path);
}
@@ -195,7 +195,7 @@ Result DirectorySaveDataFileSystem::DeleteDirectoryImpl(const FsPath &path) {
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->DeleteDirectory(full_path);
}
@@ -203,7 +203,7 @@ Result DirectorySaveDataFileSystem::DeleteDirectoryRecursivelyImpl(const FsPath
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->DeleteDirectoryRecursively(full_path);
}
@@ -212,7 +212,7 @@ Result DirectorySaveDataFileSystem::RenameFileImpl(const FsPath &old_path, const
R_TRY(GetFullPath(full_old_path, old_path));
R_TRY(GetFullPath(full_new_path, new_path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->RenameFile(full_old_path, full_new_path);
}
@@ -221,7 +221,7 @@ Result DirectorySaveDataFileSystem::RenameDirectoryImpl(const FsPath &old_path,
R_TRY(GetFullPath(full_old_path, old_path));
R_TRY(GetFullPath(full_new_path, new_path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->RenameDirectory(full_old_path, full_new_path);
}
@@ -229,7 +229,7 @@ Result DirectorySaveDataFileSystem::GetEntryTypeImpl(DirectoryEntryType *out, co
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->GetEntryType(out, full_path);
}
@@ -237,7 +237,7 @@ Result DirectorySaveDataFileSystem::OpenFileImpl(std::unique_ptr<IFile> &out_fil
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
{
/* Open the raw file. */
@@ -265,7 +265,7 @@ Result DirectorySaveDataFileSystem::OpenDirectoryImpl(std::unique_ptr<IDirectory
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->OpenDirectory(out_dir, full_path, mode);
}
@@ -278,7 +278,7 @@ Result DirectorySaveDataFileSystem::CommitImpl() {
/* will be deleted if there is an error during synchronization. */
/* Instead, we will synchronize first, then delete committed, then rename. */
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
/* Ensure we don't have any open writable files. */
if (this->open_writable_files != 0) {
@@ -320,7 +320,7 @@ Result DirectorySaveDataFileSystem::CleanDirectoryRecursivelyImpl(const FsPath &
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->CleanDirectoryRecursively(full_path);
}

View File

@@ -37,7 +37,7 @@ class DirectorySaveDataFileSystem : public IFileSystem {
std::unique_ptr<IFileSystem> unique_fs;
std::unique_ptr<IFileSystem> proxy_save_fs;
IFileSystem *fs;
HosMutex lock;
sts::os::Mutex lock;
size_t open_writable_files = 0;
public:

View File

@@ -20,7 +20,7 @@
#include "fsmitm_boot0storage.hpp"
static HosMutex g_boot0_mutex;
static sts::os::Mutex g_boot0_mutex;
static u8 g_boot0_bct_buffer[Boot0Storage::BctEndOffset];
bool Boot0Storage::CanModifyBctPubks() {
@@ -37,13 +37,13 @@ bool Boot0Storage::CanModifyBctPubks() {
}
Result Boot0Storage::Read(void *_buffer, size_t size, u64 offset) {
std::scoped_lock<HosMutex> lk{g_boot0_mutex};
std::scoped_lock lk{g_boot0_mutex};
return Base::Read(_buffer, size, offset);
}
Result Boot0Storage::Write(void *_buffer, size_t size, u64 offset) {
std::scoped_lock<HosMutex> lk{g_boot0_mutex};
std::scoped_lock lk{g_boot0_mutex};
u8 *buffer = static_cast<u8 *>(_buffer);

View File

@@ -36,11 +36,11 @@
#include "../debug.hpp"
static HosMutex g_StorageCacheLock;
static sts::os::Mutex g_StorageCacheLock;
static std::unordered_map<u64, std::weak_ptr<IStorageInterface>> g_StorageCache;
static bool StorageCacheGetEntry(sts::ncm::TitleId title_id, std::shared_ptr<IStorageInterface> *out) {
std::scoped_lock<HosMutex> lock(g_StorageCacheLock);
std::scoped_lock lock(g_StorageCacheLock);
if (g_StorageCache.find(static_cast<u64>(title_id)) == g_StorageCache.end()) {
return false;
}
@@ -54,7 +54,7 @@ static bool StorageCacheGetEntry(sts::ncm::TitleId title_id, std::shared_ptr<ISt
}
static void StorageCacheSetEntry(sts::ncm::TitleId title_id, std::shared_ptr<IStorageInterface> *ptr) {
std::scoped_lock<HosMutex> lock(g_StorageCacheLock);
std::scoped_lock lock(g_StorageCacheLock);
/* Ensure we always use the cached copy if present. */
if (g_StorageCache.find(static_cast<u64>(title_id)) != g_StorageCache.end()) {