strat: use m_ for member variables
This commit is contained in:
@@ -19,21 +19,21 @@
|
||||
|
||||
namespace ams::fs::impl {
|
||||
|
||||
DirectoryAccessor::DirectoryAccessor(std::unique_ptr<fsa::IDirectory>&& d, FileSystemAccessor &p) : impl(std::move(d)), parent(p) {
|
||||
DirectoryAccessor::DirectoryAccessor(std::unique_ptr<fsa::IDirectory>&& d, FileSystemAccessor &p) : m_impl(std::move(d)), m_parent(p) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
DirectoryAccessor::~DirectoryAccessor() {
|
||||
this->impl.reset();
|
||||
this->parent.NotifyCloseDirectory(this);
|
||||
m_impl.reset();
|
||||
m_parent.NotifyCloseDirectory(this);
|
||||
}
|
||||
|
||||
Result DirectoryAccessor::Read(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) {
|
||||
return this->impl->Read(out_count, out_entries, max_entries);
|
||||
return m_impl->Read(out_count, out_entries, max_entries);
|
||||
}
|
||||
|
||||
Result DirectoryAccessor::GetEntryCount(s64 *out) {
|
||||
return this->impl->GetEntryCount(out);
|
||||
return m_impl->GetEntryCount(out);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace ams::fs::impl {
|
||||
class DirectoryAccessor : public util::IntrusiveListBaseNode<DirectoryAccessor>, public Newable {
|
||||
NON_COPYABLE(DirectoryAccessor);
|
||||
private:
|
||||
std::unique_ptr<fsa::IDirectory> impl;
|
||||
FileSystemAccessor &parent;
|
||||
std::unique_ptr<fsa::IDirectory> m_impl;
|
||||
FileSystemAccessor &m_parent;
|
||||
public:
|
||||
DirectoryAccessor(std::unique_ptr<fsa::IDirectory>&& d, FileSystemAccessor &p);
|
||||
~DirectoryAccessor();
|
||||
@@ -32,7 +32,7 @@ namespace ams::fs::impl {
|
||||
Result Read(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries);
|
||||
Result GetEntryCount(s64 *out);
|
||||
|
||||
FileSystemAccessor *GetParent() const { return std::addressof(this->parent); }
|
||||
FileSystemAccessor *GetParent() const { return std::addressof(m_parent); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -22,20 +22,20 @@
|
||||
namespace ams::fs::impl {
|
||||
|
||||
FileAccessor::FileAccessor(std::unique_ptr<fsa::IFile>&& f, FileSystemAccessor *p, OpenMode mode)
|
||||
: impl(std::move(f)), parent(p), write_state(WriteState::None), write_result(ResultSuccess()), open_mode(mode)
|
||||
: m_impl(std::move(f)), m_parent(p), m_write_state(WriteState::None), m_write_result(ResultSuccess()), m_open_mode(mode)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
FileAccessor::~FileAccessor() {
|
||||
/* Ensure that all files are flushed. */
|
||||
if (R_SUCCEEDED(this->write_result)) {
|
||||
AMS_FS_ABORT_UNLESS_WITH_RESULT(this->write_state != WriteState::NeedsFlush, fs::ResultNeedFlush());
|
||||
if (R_SUCCEEDED(m_write_result)) {
|
||||
AMS_FS_ABORT_UNLESS_WITH_RESULT(m_write_state != WriteState::NeedsFlush, fs::ResultNeedFlush());
|
||||
}
|
||||
this->impl.reset();
|
||||
m_impl.reset();
|
||||
|
||||
if (this->parent != nullptr) {
|
||||
this->parent->NotifyCloseFile(this);
|
||||
if (m_parent != nullptr) {
|
||||
m_parent->NotifyCloseFile(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace ams::fs::impl {
|
||||
}
|
||||
|
||||
Result FileAccessor::ReadWithoutCacheAccessLog(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option) {
|
||||
return this->impl->Read(out, offset, buf, size, option);
|
||||
return m_impl->Read(out, offset, buf, size, option);
|
||||
}
|
||||
|
||||
Result FileAccessor::Read(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option) {
|
||||
@@ -54,11 +54,11 @@ namespace ams::fs::impl {
|
||||
FileHandle handle = { this };
|
||||
|
||||
/* Fail after a write fails. */
|
||||
R_UNLESS(R_SUCCEEDED(this->write_result), AMS_FS_IMPL_ACCESS_LOG_WITH_NAME(this->write_result, handle, "ReadFile", AMS_FS_IMPL_ACCESS_LOG_FORMAT_READ_FILE(out, offset, size)));
|
||||
R_UNLESS(R_SUCCEEDED(m_write_result), AMS_FS_IMPL_ACCESS_LOG_WITH_NAME(m_write_result, handle, "ReadFile", AMS_FS_IMPL_ACCESS_LOG_FORMAT_READ_FILE(out, offset, size)));
|
||||
|
||||
/* TODO: Support cache. */
|
||||
const bool use_path_cache = this->parent != nullptr && this->file_path_hash != nullptr;
|
||||
const bool use_data_cache = /* TODO */false && this->parent != nullptr && this->parent->IsFileDataCacheAttachable();
|
||||
const bool use_path_cache = m_parent != nullptr && m_file_path_hash != nullptr;
|
||||
const bool use_data_cache = /* TODO */false && m_parent != nullptr && m_parent->IsFileDataCacheAttachable();
|
||||
|
||||
if (use_path_cache && use_data_cache && false) {
|
||||
/* TODO */
|
||||
@@ -70,14 +70,14 @@ namespace ams::fs::impl {
|
||||
|
||||
Result FileAccessor::Write(s64 offset, const void *buf, size_t size, const WriteOption &option) {
|
||||
/* Fail after a write fails. */
|
||||
R_TRY(this->write_result);
|
||||
R_TRY(m_write_result);
|
||||
|
||||
auto setter = MakeScopedSetter(this->write_state, WriteState::Failed);
|
||||
if (this->file_path_hash != nullptr && /* TODO */ false) {
|
||||
auto setter = MakeScopedSetter(m_write_state, WriteState::Failed);
|
||||
if (m_file_path_hash != nullptr && /* TODO */ false) {
|
||||
/* TODO */
|
||||
AMS_ABORT();
|
||||
} else {
|
||||
R_TRY(this->UpdateLastResult(this->impl->Write(offset, buf, size, option)));
|
||||
R_TRY(this->UpdateLastResult(m_impl->Write(offset, buf, size, option)));
|
||||
}
|
||||
|
||||
setter.Set(option.HasFlushFlag() ? WriteState::None : WriteState::NeedsFlush);
|
||||
@@ -87,10 +87,10 @@ namespace ams::fs::impl {
|
||||
|
||||
Result FileAccessor::Flush() {
|
||||
/* Fail after a write fails. */
|
||||
R_TRY(this->write_result);
|
||||
R_TRY(m_write_result);
|
||||
|
||||
auto setter = MakeScopedSetter(this->write_state, WriteState::Failed);
|
||||
R_TRY(this->UpdateLastResult(this->impl->Flush()));
|
||||
auto setter = MakeScopedSetter(m_write_state, WriteState::Failed);
|
||||
R_TRY(this->UpdateLastResult(m_impl->Flush()));
|
||||
setter.Set(WriteState::None);
|
||||
|
||||
return ResultSuccess();
|
||||
@@ -98,14 +98,14 @@ namespace ams::fs::impl {
|
||||
|
||||
Result FileAccessor::SetSize(s64 size) {
|
||||
/* Fail after a write fails. */
|
||||
R_TRY(this->write_result);
|
||||
R_TRY(m_write_result);
|
||||
|
||||
const WriteState old_write_state = this->write_state;
|
||||
auto setter = MakeScopedSetter(this->write_state, WriteState::Failed);
|
||||
const WriteState old_write_state = m_write_state;
|
||||
auto setter = MakeScopedSetter(m_write_state, WriteState::Failed);
|
||||
|
||||
R_TRY(this->UpdateLastResult(this->impl->SetSize(size)));
|
||||
R_TRY(this->UpdateLastResult(m_impl->SetSize(size)));
|
||||
|
||||
if (this->file_path_hash != nullptr) {
|
||||
if (m_file_path_hash != nullptr) {
|
||||
/* TODO: invalidate path cache */
|
||||
}
|
||||
|
||||
@@ -115,13 +115,13 @@ namespace ams::fs::impl {
|
||||
|
||||
Result FileAccessor::GetSize(s64 *out) {
|
||||
/* Fail after a write fails. */
|
||||
R_TRY(this->write_result);
|
||||
R_TRY(m_write_result);
|
||||
|
||||
return this->impl->GetSize(out);
|
||||
return m_impl->GetSize(out);
|
||||
}
|
||||
|
||||
Result FileAccessor::OperateRange(void *dst, size_t dst_size, OperationId operation, s64 offset, s64 size, const void *src, size_t src_size) {
|
||||
return this->impl->OperateRange(dst, dst_size, operation, offset, size, src, src_size);
|
||||
return m_impl->OperateRange(dst, dst_size, operation, offset, size, src, src_size);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,13 +30,13 @@ namespace ams::fs::impl {
|
||||
class FileAccessor : public util::IntrusiveListBaseNode<FileAccessor>, public Newable {
|
||||
NON_COPYABLE(FileAccessor);
|
||||
private:
|
||||
std::unique_ptr<fsa::IFile> impl;
|
||||
FileSystemAccessor * const parent;
|
||||
WriteState write_state;
|
||||
Result write_result;
|
||||
const OpenMode open_mode;
|
||||
std::unique_ptr<FilePathHash> file_path_hash;
|
||||
s32 path_hash_index;
|
||||
std::unique_ptr<fsa::IFile> m_impl;
|
||||
FileSystemAccessor * const m_parent;
|
||||
WriteState m_write_state;
|
||||
Result m_write_result;
|
||||
const OpenMode m_open_mode;
|
||||
std::unique_ptr<FilePathHash> m_file_path_hash;
|
||||
s32 m_path_hash_index;
|
||||
public:
|
||||
FileAccessor(std::unique_ptr<fsa::IFile>&& f, FileSystemAccessor *p, OpenMode mode);
|
||||
~FileAccessor();
|
||||
@@ -48,9 +48,9 @@ namespace ams::fs::impl {
|
||||
Result GetSize(s64 *out);
|
||||
Result OperateRange(void *dst, size_t dst_size, OperationId operation, s64 offset, s64 size, const void *src, size_t src_size);
|
||||
|
||||
OpenMode GetOpenMode() const { return this->open_mode; }
|
||||
WriteState GetWriteState() const { return this->write_state; }
|
||||
FileSystemAccessor *GetParent() const { return this->parent; }
|
||||
OpenMode GetOpenMode() const { return m_open_mode; }
|
||||
WriteState GetWriteState() const { return m_write_state; }
|
||||
FileSystemAccessor *GetParent() const { return m_parent; }
|
||||
|
||||
void SetFilePathHash(std::unique_ptr<FilePathHash>&& file_path_hash, s32 index);
|
||||
Result ReadWithoutCacheAccessLog(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option);
|
||||
@@ -59,7 +59,7 @@ namespace ams::fs::impl {
|
||||
|
||||
ALWAYS_INLINE Result UpdateLastResult(Result r) {
|
||||
if (!fs::ResultNotEnoughFreeSpace::Includes(r)) {
|
||||
this->write_result = r;
|
||||
m_write_result = r;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -60,34 +60,34 @@ namespace ams::fs::impl {
|
||||
}
|
||||
|
||||
FileSystemAccessor::FileSystemAccessor(const char *n, std::unique_ptr<fsa::IFileSystem> &&fs, std::unique_ptr<fsa::ICommonMountNameGenerator> &&generator)
|
||||
: impl(std::move(fs)), open_list_lock(), mount_name_generator(std::move(generator)),
|
||||
access_log_enabled(false), data_cache_attachable(false), path_cache_attachable(false), path_cache_attached(false), multi_commit_supported(false)
|
||||
: m_impl(std::move(fs)), m_open_list_lock(), m_mount_name_generator(std::move(generator)),
|
||||
m_access_log_enabled(false), m_data_cache_attachable(false), m_path_cache_attachable(false), m_path_cache_attached(false), m_multi_commit_supported(false)
|
||||
{
|
||||
R_ABORT_UNLESS(ValidateMountName(n));
|
||||
std::strncpy(this->name.str, n, MountNameLengthMax);
|
||||
this->name.str[MountNameLengthMax] = 0;
|
||||
std::strncpy(m_name.str, n, MountNameLengthMax);
|
||||
m_name.str[MountNameLengthMax] = 0;
|
||||
}
|
||||
|
||||
FileSystemAccessor::~FileSystemAccessor() {
|
||||
std::scoped_lock lk(this->open_list_lock);
|
||||
std::scoped_lock lk(m_open_list_lock);
|
||||
|
||||
/* TODO: Iterate over list entries. */
|
||||
|
||||
if (!this->open_file_list.empty()) { R_ABORT_UNLESS(fs::ResultFileNotClosed()); }
|
||||
if (!this->open_dir_list.empty()) { R_ABORT_UNLESS(fs::ResultDirectoryNotClosed()); }
|
||||
if (!m_open_file_list.empty()) { R_ABORT_UNLESS(fs::ResultFileNotClosed()); }
|
||||
if (!m_open_dir_list.empty()) { R_ABORT_UNLESS(fs::ResultDirectoryNotClosed()); }
|
||||
|
||||
if (this->path_cache_attached) {
|
||||
if (m_path_cache_attached) {
|
||||
/* TODO: Invalidate path cache */
|
||||
}
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::GetCommonMountName(char *dst, size_t dst_size) const {
|
||||
R_UNLESS(this->mount_name_generator != nullptr, fs::ResultPreconditionViolation());
|
||||
return this->mount_name_generator->GenerateCommonMountName(dst, dst_size);
|
||||
R_UNLESS(m_mount_name_generator != nullptr, fs::ResultPreconditionViolation());
|
||||
return m_mount_name_generator->GenerateCommonMountName(dst, dst_size);
|
||||
}
|
||||
|
||||
std::shared_ptr<fssrv::impl::FileSystemInterfaceAdapter> FileSystemAccessor::GetMultiCommitTarget() {
|
||||
if (this->multi_commit_supported) {
|
||||
if (m_multi_commit_supported) {
|
||||
/* TODO: Support multi commit. */
|
||||
AMS_ABORT();
|
||||
}
|
||||
@@ -95,90 +95,90 @@ namespace ams::fs::impl {
|
||||
}
|
||||
|
||||
void FileSystemAccessor::NotifyCloseFile(FileAccessor *f) {
|
||||
std::scoped_lock lk(this->open_list_lock);
|
||||
Remove(this->open_file_list, f);
|
||||
std::scoped_lock lk(m_open_list_lock);
|
||||
Remove(m_open_file_list, f);
|
||||
}
|
||||
|
||||
void FileSystemAccessor::NotifyCloseDirectory(DirectoryAccessor *d) {
|
||||
std::scoped_lock lk(this->open_list_lock);
|
||||
Remove(this->open_dir_list, d);
|
||||
std::scoped_lock lk(m_open_list_lock);
|
||||
Remove(m_open_dir_list, d);
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::CreateFile(const char *path, s64 size, int option) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
if (this->path_cache_attached) {
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
if (m_path_cache_attached) {
|
||||
/* TODO: Path cache */
|
||||
R_TRY(this->impl->CreateFile(path, size, option));
|
||||
R_TRY(m_impl->CreateFile(path, size, option));
|
||||
} else {
|
||||
R_TRY(this->impl->CreateFile(path, size, option));
|
||||
R_TRY(m_impl->CreateFile(path, size, option));
|
||||
}
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::DeleteFile(const char *path) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
return this->impl->DeleteFile(path);
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
return m_impl->DeleteFile(path);
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::CreateDirectory(const char *path) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
return this->impl->CreateDirectory(path);
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
return m_impl->CreateDirectory(path);
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::DeleteDirectory(const char *path) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
return this->impl->DeleteDirectory(path);
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
return m_impl->DeleteDirectory(path);
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::DeleteDirectoryRecursively(const char *path) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
return this->impl->DeleteDirectoryRecursively(path);
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
return m_impl->DeleteDirectoryRecursively(path);
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::RenameFile(const char *old_path, const char *new_path) {
|
||||
R_TRY(ValidatePath(this->name.str, old_path));
|
||||
R_TRY(ValidatePath(this->name.str, new_path));
|
||||
if (this->path_cache_attached) {
|
||||
R_TRY(ValidatePath(m_name.str, old_path));
|
||||
R_TRY(ValidatePath(m_name.str, new_path));
|
||||
if (m_path_cache_attached) {
|
||||
/* TODO: Path cache */
|
||||
R_TRY(this->impl->RenameFile(old_path, new_path));
|
||||
R_TRY(m_impl->RenameFile(old_path, new_path));
|
||||
} else {
|
||||
R_TRY(this->impl->RenameFile(old_path, new_path));
|
||||
R_TRY(m_impl->RenameFile(old_path, new_path));
|
||||
}
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::RenameDirectory(const char *old_path, const char *new_path) {
|
||||
R_TRY(ValidatePath(this->name.str, old_path));
|
||||
R_TRY(ValidatePath(this->name.str, new_path));
|
||||
if (this->path_cache_attached) {
|
||||
R_TRY(ValidatePath(m_name.str, old_path));
|
||||
R_TRY(ValidatePath(m_name.str, new_path));
|
||||
if (m_path_cache_attached) {
|
||||
/* TODO: Path cache */
|
||||
R_TRY(this->impl->RenameDirectory(old_path, new_path));
|
||||
R_TRY(m_impl->RenameDirectory(old_path, new_path));
|
||||
} else {
|
||||
R_TRY(this->impl->RenameDirectory(old_path, new_path));
|
||||
R_TRY(m_impl->RenameDirectory(old_path, new_path));
|
||||
}
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::GetEntryType(DirectoryEntryType *out, const char *path) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
return this->impl->GetEntryType(out, path);
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
return m_impl->GetEntryType(out, path);
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::OpenFile(std::unique_ptr<FileAccessor> *out_file, const char *path, OpenMode mode) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
|
||||
std::unique_ptr<fsa::IFile> file;
|
||||
R_TRY(this->impl->OpenFile(std::addressof(file), path, mode));
|
||||
R_TRY(m_impl->OpenFile(std::addressof(file), path, mode));
|
||||
|
||||
auto accessor = new FileAccessor(std::move(file), this, mode);
|
||||
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInFileSystemAccessorA());
|
||||
|
||||
{
|
||||
std::scoped_lock lk(this->open_list_lock);
|
||||
this->open_file_list.push_back(*accessor);
|
||||
std::scoped_lock lk(m_open_list_lock);
|
||||
m_open_file_list.push_back(*accessor);
|
||||
}
|
||||
|
||||
if (this->path_cache_attached) {
|
||||
if (m_path_cache_attached) {
|
||||
if (mode & OpenMode_AllowAppend) {
|
||||
/* TODO: Append Path cache */
|
||||
} else {
|
||||
@@ -191,17 +191,17 @@ namespace ams::fs::impl {
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::OpenDirectory(std::unique_ptr<DirectoryAccessor> *out_dir, const char *path, OpenDirectoryMode mode) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
|
||||
std::unique_ptr<fsa::IDirectory> dir;
|
||||
R_TRY(this->impl->OpenDirectory(std::addressof(dir), path, mode));
|
||||
R_TRY(m_impl->OpenDirectory(std::addressof(dir), path, mode));
|
||||
|
||||
auto accessor = new DirectoryAccessor(std::move(dir), *this);
|
||||
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInFileSystemAccessorB());
|
||||
|
||||
{
|
||||
std::scoped_lock lk(this->open_list_lock);
|
||||
this->open_dir_list.push_back(*accessor);
|
||||
std::scoped_lock lk(m_open_list_lock);
|
||||
m_open_dir_list.push_back(*accessor);
|
||||
}
|
||||
|
||||
out_dir->reset(accessor);
|
||||
@@ -210,33 +210,33 @@ namespace ams::fs::impl {
|
||||
|
||||
Result FileSystemAccessor::Commit() {
|
||||
{
|
||||
std::scoped_lock lk(this->open_list_lock);
|
||||
R_ABORT_UNLESS(ValidateNoOpenWriteModeFiles(this->open_file_list));
|
||||
std::scoped_lock lk(m_open_list_lock);
|
||||
R_ABORT_UNLESS(ValidateNoOpenWriteModeFiles(m_open_file_list));
|
||||
}
|
||||
return this->impl->Commit();
|
||||
return m_impl->Commit();
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::GetFreeSpaceSize(s64 *out, const char *path) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
return this->impl->GetFreeSpaceSize(out, path);
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
return m_impl->GetFreeSpaceSize(out, path);
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::GetTotalSpaceSize(s64 *out, const char *path) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
return this->impl->GetTotalSpaceSize(out, path);
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
return m_impl->GetTotalSpaceSize(out, path);
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::CleanDirectoryRecursively(const char *path) {
|
||||
R_TRY(ValidatePath(this->name.str, path));
|
||||
return this->impl->CleanDirectoryRecursively(path);
|
||||
R_TRY(ValidatePath(m_name.str, path));
|
||||
return m_impl->CleanDirectoryRecursively(path);
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::GetFileTimeStampRaw(FileTimeStampRaw *out, const char *path) {
|
||||
return this->impl->GetFileTimeStampRaw(out, path);
|
||||
return m_impl->GetFileTimeStampRaw(out, path);
|
||||
}
|
||||
|
||||
Result FileSystemAccessor::QueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fsa::QueryId query, const char *path) {
|
||||
return this->impl->QueryEntry(dst, dst_size, src, src_size, query, path);
|
||||
return m_impl->QueryEntry(dst, dst_size, src, src_size, query, path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,17 +31,17 @@ namespace ams::fs::impl {
|
||||
using FileList = util::IntrusiveListBaseTraits<FileAccessor>::ListType;
|
||||
using DirList = util::IntrusiveListBaseTraits<DirectoryAccessor>::ListType;
|
||||
private:
|
||||
MountName name;
|
||||
std::unique_ptr<fsa::IFileSystem> impl;
|
||||
FileList open_file_list;
|
||||
DirList open_dir_list;
|
||||
os::SdkMutex open_list_lock;
|
||||
std::unique_ptr<fsa::ICommonMountNameGenerator> mount_name_generator;
|
||||
bool access_log_enabled;
|
||||
bool data_cache_attachable;
|
||||
bool path_cache_attachable;
|
||||
bool path_cache_attached;
|
||||
bool multi_commit_supported;
|
||||
MountName m_name;
|
||||
std::unique_ptr<fsa::IFileSystem> m_impl;
|
||||
FileList m_open_file_list;
|
||||
DirList m_open_dir_list;
|
||||
os::SdkMutex m_open_list_lock;
|
||||
std::unique_ptr<fsa::ICommonMountNameGenerator> m_mount_name_generator;
|
||||
bool m_access_log_enabled;
|
||||
bool m_data_cache_attachable;
|
||||
bool m_path_cache_attachable;
|
||||
bool m_path_cache_attached;
|
||||
bool m_multi_commit_supported;
|
||||
public:
|
||||
FileSystemAccessor(const char *name, std::unique_ptr<fsa::IFileSystem> &&fs, std::unique_ptr<fsa::ICommonMountNameGenerator> &&generator = nullptr);
|
||||
virtual ~FileSystemAccessor();
|
||||
@@ -63,32 +63,32 @@ namespace ams::fs::impl {
|
||||
Result GetFileTimeStampRaw(FileTimeStampRaw *out, const char *path);
|
||||
Result QueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fsa::QueryId query, const char *path);
|
||||
|
||||
const char *GetName() const { return this->name.str; }
|
||||
const char *GetName() const { return m_name.str; }
|
||||
Result GetCommonMountName(char *dst, size_t dst_size) const;
|
||||
|
||||
void SetAccessLogEnabled(bool en) { this->access_log_enabled = en; }
|
||||
void SetFileDataCacheAttachable(bool en) { this->data_cache_attachable = en; }
|
||||
void SetPathBasedFileDataCacheAttachable(bool en) { this->path_cache_attachable = en; }
|
||||
void SetMultiCommitSupported(bool en) { this->multi_commit_supported = en; }
|
||||
void SetAccessLogEnabled(bool en) { m_access_log_enabled = en; }
|
||||
void SetFileDataCacheAttachable(bool en) { m_data_cache_attachable = en; }
|
||||
void SetPathBasedFileDataCacheAttachable(bool en) { m_path_cache_attachable = en; }
|
||||
void SetMultiCommitSupported(bool en) { m_multi_commit_supported = en; }
|
||||
|
||||
bool IsEnabledAccessLog() const { return this->access_log_enabled; }
|
||||
bool IsFileDataCacheAttachable() const { return this->data_cache_attachable; }
|
||||
bool IsPathBasedFileDataCacheAttachable() const { return this->path_cache_attachable; }
|
||||
bool IsEnabledAccessLog() const { return m_access_log_enabled; }
|
||||
bool IsFileDataCacheAttachable() const { return m_data_cache_attachable; }
|
||||
bool IsPathBasedFileDataCacheAttachable() const { return m_path_cache_attachable; }
|
||||
|
||||
void AttachPathBasedFileDataCache() {
|
||||
if (this->IsPathBasedFileDataCacheAttachable()) {
|
||||
this->path_cache_attached = true;
|
||||
m_path_cache_attached = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DetachPathBasedFileDataCache() {
|
||||
this->path_cache_attached = false;
|
||||
m_path_cache_attached = false;
|
||||
}
|
||||
|
||||
std::shared_ptr<fssrv::impl::FileSystemInterfaceAdapter> GetMultiCommitTarget();
|
||||
|
||||
fsa::IFileSystem *GetRawFileSystemUnsafe() {
|
||||
return this->impl.get();
|
||||
return m_impl.get();
|
||||
}
|
||||
private:
|
||||
void NotifyCloseFile(FileAccessor *f);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace ams::fs::impl {
|
||||
}
|
||||
|
||||
bool MountTable::CanAcceptMountName(const char *name) {
|
||||
for (const auto &fs : this->fs_list) {
|
||||
for (const auto &fs : m_fs_list) {
|
||||
if (MatchesName(fs, name)) {
|
||||
return false;
|
||||
}
|
||||
@@ -36,18 +36,18 @@ namespace ams::fs::impl {
|
||||
}
|
||||
|
||||
Result MountTable::Mount(std::unique_ptr<FileSystemAccessor> &&fs) {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
R_UNLESS(this->CanAcceptMountName(fs->GetName()), fs::ResultMountNameAlreadyExists());
|
||||
|
||||
this->fs_list.push_back(*fs.release());
|
||||
m_fs_list.push_back(*fs.release());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result MountTable::Find(FileSystemAccessor **out, const char *name) {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
for (auto &fs : this->fs_list) {
|
||||
for (auto &fs : m_fs_list) {
|
||||
if (MatchesName(fs, name)) {
|
||||
*out = std::addressof(fs);
|
||||
return ResultSuccess();
|
||||
@@ -58,12 +58,12 @@ namespace ams::fs::impl {
|
||||
}
|
||||
|
||||
void MountTable::Unmount(const char *name) {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
for (auto it = this->fs_list.cbegin(); it != this->fs_list.cend(); it++) {
|
||||
for (auto it = m_fs_list.cbegin(); it != m_fs_list.cend(); it++) {
|
||||
if (MatchesName(*it, name)) {
|
||||
auto p = std::addressof(*it);
|
||||
this->fs_list.erase(it);
|
||||
m_fs_list.erase(it);
|
||||
delete p;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace ams::fs::impl {
|
||||
private:
|
||||
using FileSystemList = util::IntrusiveListBaseTraits<FileSystemAccessor>::ListType;
|
||||
private:
|
||||
FileSystemList fs_list;
|
||||
os::SdkMutex mutex;
|
||||
FileSystemList m_fs_list;
|
||||
os::SdkMutex m_mutex;
|
||||
public:
|
||||
constexpr MountTable() : fs_list(), mutex() { /* ... */ }
|
||||
constexpr MountTable() : m_fs_list(), m_mutex() { /* ... */ }
|
||||
private:
|
||||
bool CanAcceptMountName(const char *name);
|
||||
public:
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace ams::fs::impl {
|
||||
|
||||
namespace {
|
||||
|
||||
MountTable g_mount_table;
|
||||
constinit MountTable g_mount_table;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user