clang format

This commit is contained in:
Vitor Kiguchi 2021-03-24 12:47:45 -03:00
parent a10f9b574b
commit 90eb10aa0f
6 changed files with 55 additions and 30 deletions

View file

@ -5,9 +5,9 @@
#include <cstddef> #include <cstddef>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "common/file_util.h"
#include "core/file_sys/archive_backend.h" #include "core/file_sys/archive_backend.h"
#include "core/memory.h" #include "core/memory.h"

View file

@ -198,6 +198,7 @@ public:
protected: protected:
std::unique_ptr<DelayGenerator> delay_generator; std::unique_ptr<DelayGenerator> delay_generator;
static std::string base_path; static std::string base_path;
private: private:
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) { void serialize(Archive& ar, const unsigned int) {
@ -243,6 +244,7 @@ public:
static std::string sdmc_directory; static std::string sdmc_directory;
static std::string nand_directory; static std::string nand_directory;
private: private:
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) {} void serialize(Archive& ar, const unsigned int) {}

View file

@ -81,7 +81,8 @@ ResultVal<std::unique_ptr<FileBackend>> SDMCArchive::OpenFileBase(const Path& pa
switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) { switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}",
ArchiveBackend::base_path + mount_point);
return ERROR_NOT_FOUND; return ERROR_NOT_FOUND;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::FileInPath: case PathParser::FileInPath:
@ -127,7 +128,8 @@ ResultCode SDMCArchive::DeleteFile(const Path& path) const {
switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) { switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}",
ArchiveBackend::base_path + mount_point);
return ERROR_NOT_FOUND; return ERROR_NOT_FOUND;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::FileInPath: case PathParser::FileInPath:
@ -165,8 +167,10 @@ ResultCode SDMCArchive::RenameFile(const Path& src_path, const Path& dest_path)
return ERROR_INVALID_PATH; return ERROR_INVALID_PATH;
} }
const auto src_path_full = path_parser_src.BuildHostPath(ArchiveBackend::base_path + mount_point); const auto src_path_full =
const auto dest_path_full = path_parser_dest.BuildHostPath(ArchiveBackend::base_path + mount_point); path_parser_src.BuildHostPath(ArchiveBackend::base_path + mount_point);
const auto dest_path_full =
path_parser_dest.BuildHostPath(ArchiveBackend::base_path + mount_point);
if (FileUtil::Rename(src_path_full, dest_path_full)) { if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -218,12 +222,14 @@ static ResultCode DeleteDirectoryHelper(const Path& path, const std::string& mou
} }
ResultCode SDMCArchive::DeleteDirectory(const Path& path) const { ResultCode SDMCArchive::DeleteDirectory(const Path& path) const {
return DeleteDirectoryHelper(path, ArchiveBackend::base_path + mount_point, FileUtil::DeleteDir); return DeleteDirectoryHelper(path, ArchiveBackend::base_path + mount_point,
FileUtil::DeleteDir);
} }
ResultCode SDMCArchive::DeleteDirectoryRecursively(const Path& path) const { ResultCode SDMCArchive::DeleteDirectoryRecursively(const Path& path) const {
return DeleteDirectoryHelper( return DeleteDirectoryHelper(
path, ArchiveBackend::base_path + mount_point, [](const std::string& p) { return FileUtil::DeleteDirRecursively(p); }); path, ArchiveBackend::base_path + mount_point,
[](const std::string& p) { return FileUtil::DeleteDirRecursively(p); });
} }
ResultCode SDMCArchive::CreateFile(const FileSys::Path& path, u64 size) const { ResultCode SDMCArchive::CreateFile(const FileSys::Path& path, u64 size) const {
@ -238,7 +244,8 @@ ResultCode SDMCArchive::CreateFile(const FileSys::Path& path, u64 size) const {
switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) { switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}",
ArchiveBackend::base_path + mount_point);
return ERROR_NOT_FOUND; return ERROR_NOT_FOUND;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::FileInPath: case PathParser::FileInPath:
@ -283,7 +290,8 @@ ResultCode SDMCArchive::CreateDirectory(const Path& path) const {
switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) { switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}",
ArchiveBackend::base_path + mount_point);
return ERROR_NOT_FOUND; return ERROR_NOT_FOUND;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::FileInPath: case PathParser::FileInPath:
@ -301,7 +309,8 @@ ResultCode SDMCArchive::CreateDirectory(const Path& path) const {
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}",
ArchiveBackend::base_path + mount_point);
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled,
ErrorLevel::Status); ErrorLevel::Status);
} }
@ -322,8 +331,10 @@ ResultCode SDMCArchive::RenameDirectory(const Path& src_path, const Path& dest_p
return ERROR_INVALID_PATH; return ERROR_INVALID_PATH;
} }
const auto src_path_full = path_parser_src.BuildHostPath(ArchiveBackend::base_path + mount_point); const auto src_path_full =
const auto dest_path_full = path_parser_dest.BuildHostPath(ArchiveBackend::base_path + mount_point); path_parser_src.BuildHostPath(ArchiveBackend::base_path + mount_point);
const auto dest_path_full =
path_parser_dest.BuildHostPath(ArchiveBackend::base_path + mount_point);
if (FileUtil::Rename(src_path_full, dest_path_full)) { if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -347,7 +358,8 @@ ResultVal<std::unique_ptr<DirectoryBackend>> SDMCArchive::OpenDirectory(const Pa
switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) { switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}",
ArchiveBackend::base_path + mount_point);
return ERROR_NOT_FOUND; return ERROR_NOT_FOUND;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::NotFound: case PathParser::NotFound:

View file

@ -54,7 +54,8 @@ Path ConstructSystemSaveDataBinaryPath(u32 high, u32 low) {
ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SystemSaveData::Open(const Path& path, ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SystemSaveData::Open(const Path& path,
u64 program_id) { u64 program_id) {
const std::string fullpath = GetSystemSaveDataPath(GetSystemSaveDataContainerPath(ArchiveFactory::nand_directory), path); const std::string fullpath =
GetSystemSaveDataPath(GetSystemSaveDataContainerPath(ArchiveFactory::nand_directory), path);
std::string relative_path = std::string relative_path =
GetSystemSaveDataPath(GetSystemSaveDataContainerPath("nand/"), path); GetSystemSaveDataPath(GetSystemSaveDataContainerPath("nand/"), path);
if (!FileUtil::Exists(fullpath)) { if (!FileUtil::Exists(fullpath)) {
@ -68,7 +69,8 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SystemSaveData::Open(c
ResultCode ArchiveFactory_SystemSaveData::Format(const Path& path, ResultCode ArchiveFactory_SystemSaveData::Format(const Path& path,
const FileSys::ArchiveFormatInfo& format_info, const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) { u64 program_id) {
std::string fullpath = GetSystemSaveDataPath(GetSystemSaveDataContainerPath(ArchiveFactory::nand_directory), path); std::string fullpath =
GetSystemSaveDataPath(GetSystemSaveDataContainerPath(ArchiveFactory::nand_directory), path);
FileUtil::DeleteDirRecursively(fullpath); FileUtil::DeleteDirRecursively(fullpath);
FileUtil::CreateFullPath(fullpath); FileUtil::CreateFullPath(fullpath);
return RESULT_SUCCESS; return RESULT_SUCCESS;

View file

@ -63,7 +63,8 @@ ResultVal<std::unique_ptr<FileBackend>> SaveDataArchive::OpenFile(const Path& pa
switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) { switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}",
ArchiveBackend::base_path + mount_point);
return ERROR_FILE_NOT_FOUND; return ERROR_FILE_NOT_FOUND;
case PathParser::PathNotFound: case PathParser::PathNotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
@ -109,7 +110,8 @@ ResultCode SaveDataArchive::DeleteFile(const Path& path) const {
switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) { switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}",
ArchiveBackend::base_path + mount_point);
return ERROR_FILE_NOT_FOUND; return ERROR_FILE_NOT_FOUND;
case PathParser::PathNotFound: case PathParser::PathNotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
@ -147,8 +149,10 @@ ResultCode SaveDataArchive::RenameFile(const Path& src_path, const Path& dest_pa
return ERROR_INVALID_PATH; return ERROR_INVALID_PATH;
} }
const auto src_path_full = path_parser_src.BuildHostPath(ArchiveBackend::base_path + mount_point); const auto src_path_full =
const auto dest_path_full = path_parser_dest.BuildHostPath(ArchiveBackend::base_path + mount_point); path_parser_src.BuildHostPath(ArchiveBackend::base_path + mount_point);
const auto dest_path_full =
path_parser_dest.BuildHostPath(ArchiveBackend::base_path + mount_point);
if (FileUtil::Rename(src_path_full, dest_path_full)) { if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -200,13 +204,14 @@ static ResultCode DeleteDirectoryHelper(const Path& path, const std::string& mou
} }
ResultCode SaveDataArchive::DeleteDirectory(const Path& path) const { ResultCode SaveDataArchive::DeleteDirectory(const Path& path) const {
return DeleteDirectoryHelper(path, ArchiveBackend::base_path + mount_point, FileUtil::DeleteDir); return DeleteDirectoryHelper(path, ArchiveBackend::base_path + mount_point,
FileUtil::DeleteDir);
} }
ResultCode SaveDataArchive::DeleteDirectoryRecursively(const Path& path) const { ResultCode SaveDataArchive::DeleteDirectoryRecursively(const Path& path) const {
return DeleteDirectoryHelper(path, ArchiveBackend::base_path + mount_point, [](const std::string& p) { return DeleteDirectoryHelper(
return FileUtil::DeleteDirRecursively(p); path, ArchiveBackend::base_path + mount_point,
}); [](const std::string& p) { return FileUtil::DeleteDirRecursively(p); });
} }
ResultCode SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) const { ResultCode SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) const {
@ -221,7 +226,8 @@ ResultCode SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) cons
switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) { switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}",
ArchiveBackend::base_path + mount_point);
return ERROR_FILE_NOT_FOUND; return ERROR_FILE_NOT_FOUND;
case PathParser::PathNotFound: case PathParser::PathNotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
@ -266,7 +272,8 @@ ResultCode SaveDataArchive::CreateDirectory(const Path& path) const {
switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) { switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}",
ArchiveBackend::base_path + mount_point);
return ERROR_FILE_NOT_FOUND; return ERROR_FILE_NOT_FOUND;
case PathParser::PathNotFound: case PathParser::PathNotFound:
LOG_ERROR(Service_FS, "Path not found {}", full_path); LOG_ERROR(Service_FS, "Path not found {}", full_path);
@ -308,8 +315,10 @@ ResultCode SaveDataArchive::RenameDirectory(const Path& src_path, const Path& de
return ERROR_INVALID_PATH; return ERROR_INVALID_PATH;
} }
const auto src_path_full = path_parser_src.BuildHostPath(ArchiveBackend::base_path + mount_point); const auto src_path_full =
const auto dest_path_full = path_parser_dest.BuildHostPath(ArchiveBackend::base_path + mount_point); path_parser_src.BuildHostPath(ArchiveBackend::base_path + mount_point);
const auto dest_path_full =
path_parser_dest.BuildHostPath(ArchiveBackend::base_path + mount_point);
if (FileUtil::Rename(src_path_full, dest_path_full)) { if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -334,7 +343,8 @@ ResultVal<std::unique_ptr<DirectoryBackend>> SaveDataArchive::OpenDirectory(
switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) { switch (path_parser.GetHostStatus(ArchiveBackend::base_path + mount_point)) {
case PathParser::InvalidMountPoint: case PathParser::InvalidMountPoint:
LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", ArchiveBackend::base_path + mount_point); LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}",
ArchiveBackend::base_path + mount_point);
return ERROR_FILE_NOT_FOUND; return ERROR_FILE_NOT_FOUND;
case PathParser::PathNotFound: case PathParser::PathNotFound:
case PathParser::NotFound: case PathParser::NotFound:

View file

@ -362,8 +362,7 @@ void ArchiveManager::RegisterArchiveTypes() {
auto savedatacheck_factory = std::make_unique<FileSys::ArchiveFactory_NCCH>(); auto savedatacheck_factory = std::make_unique<FileSys::ArchiveFactory_NCCH>();
RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::NCCH); RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::NCCH);
auto systemsavedata_factory = auto systemsavedata_factory = std::make_unique<FileSys::ArchiveFactory_SystemSaveData>();
std::make_unique<FileSys::ArchiveFactory_SystemSaveData>();
RegisterArchiveType(std::move(systemsavedata_factory), ArchiveIdCode::SystemSaveData); RegisterArchiveType(std::move(systemsavedata_factory), ArchiveIdCode::SystemSaveData);
auto selfncch_factory = std::make_unique<FileSys::ArchiveFactory_SelfNCCH>(); auto selfncch_factory = std::make_unique<FileSys::ArchiveFactory_SelfNCCH>();