strat: use m_ for member variables

This commit is contained in:
Michael Scire
2021-10-10 00:14:06 -07:00
parent ce28591ab2
commit a595c232b9
425 changed files with 8531 additions and 8484 deletions

View File

@@ -27,60 +27,60 @@ namespace ams::fssystem {
class DirectorySaveDataFile : public fs::fsa::IFile {
private:
std::unique_ptr<fs::fsa::IFile> base_file;
DirectorySaveDataFileSystem *parent_fs;
fs::OpenMode open_mode;
std::unique_ptr<fs::fsa::IFile> m_base_file;
DirectorySaveDataFileSystem *m_parent_fs;
fs::OpenMode m_open_mode;
public:
DirectorySaveDataFile(std::unique_ptr<fs::fsa::IFile> f, DirectorySaveDataFileSystem *p, fs::OpenMode m) : base_file(std::move(f)), parent_fs(p), open_mode(m) {
DirectorySaveDataFile(std::unique_ptr<fs::fsa::IFile> f, DirectorySaveDataFileSystem *p, fs::OpenMode m) : m_base_file(std::move(f)), m_parent_fs(p), m_open_mode(m) {
/* ... */
}
virtual ~DirectorySaveDataFile() {
/* Observe closing of writable file. */
if (this->open_mode & fs::OpenMode_Write) {
this->parent_fs->OnWritableFileClose();
if (m_open_mode & fs::OpenMode_Write) {
m_parent_fs->OnWritableFileClose();
}
}
public:
virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override {
return this->base_file->Read(out, offset, buffer, size, option);
return m_base_file->Read(out, offset, buffer, size, option);
}
virtual Result DoGetSize(s64 *out) override {
return this->base_file->GetSize(out);
return m_base_file->GetSize(out);
}
virtual Result DoFlush() override {
return this->base_file->Flush();
return m_base_file->Flush();
}
virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override {
return this->base_file->Write(offset, buffer, size, option);
return m_base_file->Write(offset, buffer, size, option);
}
virtual Result DoSetSize(s64 size) override {
return this->base_file->SetSize(size);
return m_base_file->SetSize(size);
}
virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
return this->base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size);
return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size);
}
public:
virtual sf::cmif::DomainObjectId GetDomainObjectId() const override {
return this->base_file->GetDomainObjectId();
return m_base_file->GetDomainObjectId();
}
};
}
DirectorySaveDataFileSystem::DirectorySaveDataFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs)
: PathResolutionFileSystem(fs), accessor_mutex(), open_writable_files(0)
: PathResolutionFileSystem(fs), m_accessor_mutex(), m_open_writable_files(0)
{
/* ... */
}
DirectorySaveDataFileSystem::DirectorySaveDataFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs)
: PathResolutionFileSystem(std::move(fs)), accessor_mutex(), open_writable_files(0)
: PathResolutionFileSystem(std::move(fs)), m_accessor_mutex(), m_open_writable_files(0)
{
/* ... */
}
@@ -91,25 +91,25 @@ namespace ams::fssystem {
Result DirectorySaveDataFileSystem::Initialize() {
/* Nintendo does not acquire the lock here, but I think we probably should. */
std::scoped_lock lk(this->accessor_mutex);
std::scoped_lock lk(m_accessor_mutex);
fs::DirectoryEntryType type;
/* Check that the working directory exists. */
R_TRY_CATCH(this->base_fs->GetEntryType(std::addressof(type), WorkingDirectoryPath)) {
R_TRY_CATCH(m_base_fs->GetEntryType(std::addressof(type), WorkingDirectoryPath)) {
/* If path isn't found, create working directory and committed directory. */
R_CATCH(fs::ResultPathNotFound) {
R_TRY(this->base_fs->CreateDirectory(WorkingDirectoryPath));
R_TRY(this->base_fs->CreateDirectory(CommittedDirectoryPath));
R_TRY(m_base_fs->CreateDirectory(WorkingDirectoryPath));
R_TRY(m_base_fs->CreateDirectory(CommittedDirectoryPath));
}
} R_END_TRY_CATCH;
/* Now check for the committed directory. */
R_TRY_CATCH(this->base_fs->GetEntryType(std::addressof(type), CommittedDirectoryPath)) {
R_TRY_CATCH(m_base_fs->GetEntryType(std::addressof(type), CommittedDirectoryPath)) {
/* Committed doesn't exist, so synchronize and rename. */
R_CATCH(fs::ResultPathNotFound) {
R_TRY(this->SynchronizeDirectory(SynchronizingDirectoryPath, WorkingDirectoryPath));
R_TRY(this->base_fs->RenameDirectory(SynchronizingDirectoryPath, CommittedDirectoryPath));
R_TRY(m_base_fs->RenameDirectory(SynchronizingDirectoryPath, CommittedDirectoryPath));
return ResultSuccess();
}
} R_END_TRY_CATCH;
@@ -139,11 +139,11 @@ namespace ams::fssystem {
Result DirectorySaveDataFileSystem::SynchronizeDirectory(const char *dst, const char *src) {
/* Delete destination dir and recreate it. */
R_TRY_CATCH(this->base_fs->DeleteDirectoryRecursively(dst)) {
R_TRY_CATCH(m_base_fs->DeleteDirectoryRecursively(dst)) {
R_CATCH(fs::ResultPathNotFound) { /* Nintendo returns error unconditionally, but I think that's a bug in their code. */}
} R_END_TRY_CATCH;
R_TRY(this->base_fs->CreateDirectory(dst));
R_TRY(m_base_fs->CreateDirectory(dst));
/* Get a work buffer to work with. */
std::unique_ptr<u8[]> work_buf;
@@ -151,7 +151,7 @@ namespace ams::fssystem {
R_TRY(this->AllocateWorkBuffer(std::addressof(work_buf), std::addressof(work_buf_size), IdealWorkBufferSize));
/* Copy the directory recursively. */
return fssystem::CopyDirectoryRecursively(this->base_fs, dst, src, work_buf.get(), work_buf_size);
return fssystem::CopyDirectoryRecursively(m_base_fs, dst, src, work_buf.get(), work_buf_size);
}
Result DirectorySaveDataFileSystem::ResolveFullPath(char *out, size_t out_size, const char *relative_path) {
@@ -169,11 +169,11 @@ namespace ams::fssystem {
}
void DirectorySaveDataFileSystem::OnWritableFileClose() {
std::scoped_lock lk(this->accessor_mutex);
this->open_writable_files--;
std::scoped_lock lk(m_accessor_mutex);
m_open_writable_files--;
/* Nintendo does not check this, but I think it's sensible to do so. */
AMS_ABORT_UNLESS(this->open_writable_files >= 0);
AMS_ABORT_UNLESS(m_open_writable_files >= 0);
}
Result DirectorySaveDataFileSystem::CopySaveFromFileSystem(fs::fsa::IFileSystem *save_fs) {
@@ -186,7 +186,7 @@ namespace ams::fssystem {
R_TRY(this->AllocateWorkBuffer(std::addressof(work_buf), std::addressof(work_buf_size), IdealWorkBufferSize));
/* Copy the directory recursively. */
R_TRY(fssystem::CopyDirectoryRecursively(this->base_fs, save_fs, fs::PathNormalizer::RootPath, fs::PathNormalizer::RootPath, work_buf.get(), work_buf_size));
R_TRY(fssystem::CopyDirectoryRecursively(m_base_fs, save_fs, fs::PathNormalizer::RootPath, fs::PathNormalizer::RootPath, work_buf.get(), work_buf_size));
return this->Commit();
}
@@ -196,15 +196,15 @@ namespace ams::fssystem {
char full_path[fs::EntryNameLengthMax + 1];
R_TRY(this->ResolveFullPath(full_path, sizeof(full_path), path));
std::scoped_lock lk(this->accessor_mutex);
std::scoped_lock lk(m_accessor_mutex);
std::unique_ptr<fs::fsa::IFile> base_file;
R_TRY(this->base_fs->OpenFile(std::addressof(base_file), full_path, mode));
R_TRY(m_base_fs->OpenFile(std::addressof(base_file), full_path, mode));
std::unique_ptr<DirectorySaveDataFile> file(new (std::nothrow) DirectorySaveDataFile(std::move(base_file), this, mode));
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInDirectorySaveDataFileSystem());
if (mode & fs::OpenMode_Write) {
this->open_writable_files++;
m_open_writable_files++;
}
*out_file = std::move(file);
@@ -216,13 +216,13 @@ namespace ams::fssystem {
/* - Rename Committed -> Synchronizing. */
/* - Synchronize Working -> Synchronizing (deleting Synchronizing). */
/* - Rename Synchronizing -> Committed. */
std::scoped_lock lk(this->accessor_mutex);
std::scoped_lock lk(m_accessor_mutex);
R_UNLESS(this->open_writable_files == 0, fs::ResultPreconditionViolation());
R_UNLESS(m_open_writable_files == 0, fs::ResultPreconditionViolation());
const auto RenameCommitedDir = [&]() { return this->base_fs->RenameDirectory(CommittedDirectoryPath, SynchronizingDirectoryPath); };
const auto RenameCommitedDir = [&]() { return m_base_fs->RenameDirectory(CommittedDirectoryPath, SynchronizingDirectoryPath); };
const auto SynchronizeWorkingDir = [&]() { return this->SynchronizeDirectory(SynchronizingDirectoryPath, WorkingDirectoryPath); };
const auto RenameSynchronizingDir = [&]() { return this->base_fs->RenameDirectory(SynchronizingDirectoryPath, CommittedDirectoryPath); };
const auto RenameSynchronizingDir = [&]() { return m_base_fs->RenameDirectory(SynchronizingDirectoryPath, CommittedDirectoryPath); };
/* Rename Committed -> Synchronizing. */
R_TRY(fssystem::RetryFinitelyForTargetLocked(std::move(RenameCommitedDir)));
@@ -233,7 +233,7 @@ namespace ams::fssystem {
/* - Rename Synchronizing -> Committed. */
R_TRY(fssystem::RetryFinitelyForTargetLocked(std::move(RenameSynchronizingDir)));
/* TODO: Should I call this->base_fs->Commit()? Nintendo does not. */
/* TODO: Should I call m_base_fs->Commit()? Nintendo does not. */
return ResultSuccess();
}