finish refactor, add docs and CI
CI / Build NRO (push) Failing after 3s
CI / Format check (push) Successful in 29s
CI / Layering check (push) Successful in 1s

This commit is contained in:
2026-04-27 01:49:41 +03:00
parent dc65a4c8a9
commit 12b990472d
47 changed files with 1964 additions and 1470 deletions
+4 -4
View File
@@ -28,16 +28,17 @@
#include <dirent.h>
#include <errno.h>
#include <string>
#include <switch.h>
#include <vector>
#include <switch.h>
struct DirectoryEntry {
std::string name;
bool directory;
};
class Directory {
public:
public:
Directory(const std::string& root);
~Directory() = default;
@@ -47,9 +48,8 @@ public:
bool good(void);
size_t size(void);
private:
private:
std::vector<struct DirectoryEntry> mList;
Result mError;
bool mGood;
};
+6 -6
View File
@@ -25,12 +25,12 @@
*/
#pragma once
#include <nxst/domain/account.hpp>
#include <switch.h>
namespace FileSystem {
Result mount(FsFileSystem* fileSystem, u64 titleID, AccountUid userID);
int mount(FsFileSystem fs);
void unmount(void);
}
#include <nxst/domain/account.hpp>
namespace FileSystem {
Result mount(FsFileSystem* fileSystem, u64 titleID, AccountUid userID);
int mount(FsFileSystem fs);
void unmount(void);
} // namespace FileSystem
+24 -9
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cstdio>
#include <switch.h>
namespace nxst {
@@ -10,14 +11,21 @@ struct FsFileSystemHandle {
bool valid{false};
FsFileSystemHandle() = default;
~FsFileSystemHandle() { if (valid) fsFsClose(&fs); } // NOLINT(modernize-use-equals-default)
~FsFileSystemHandle() {
if (valid)
fsFsClose(&fs);
} // NOLINT(modernize-use-equals-default)
FsFileSystemHandle(const FsFileSystemHandle&) = delete;
FsFileSystemHandle(const FsFileSystemHandle&) = delete;
FsFileSystemHandle& operator=(const FsFileSystemHandle&) = delete;
FsFileSystem* get() { return &fs; }
FsFileSystem* get() {
return &fs;
}
void release() { valid = false; } // transfer ownership to devfs
void release() {
valid = false;
} // transfer ownership to devfs
};
// RAII wrapper for FILE* — auto-fclose on destruction.
@@ -25,13 +33,20 @@ struct FileHandle {
FILE* ptr{nullptr};
explicit FileHandle(FILE* file) : ptr(file) {}
~FileHandle() { if (ptr != nullptr) fclose(ptr); } // NOLINT(modernize-use-equals-default)
~FileHandle() {
if (ptr != nullptr)
fclose(ptr);
} // NOLINT(modernize-use-equals-default)
FileHandle(const FileHandle&) = delete;
FileHandle(const FileHandle&) = delete;
FileHandle& operator=(const FileHandle&) = delete;
explicit operator bool() const { return ptr != nullptr; }
FILE* get() const { return ptr; }
explicit operator bool() const {
return ptr != nullptr;
}
FILE* get() const {
return ptr;
}
};
} // namespace nxst
} // namespace nxst
+18 -16
View File
@@ -25,27 +25,29 @@
*/
#pragma once
#include <nxst/domain/account.hpp>
#include <nxst/domain/result.hpp>
#include <nxst/infra/fs/directory.hpp>
#include <nxst/domain/title.hpp>
#include <nxst/domain/util.hpp>
#include <dirent.h>
#include <switch.h>
#include <sys/stat.h>
#include <unistd.h>
#include <switch.h>
#include <nxst/domain/account.hpp>
#include <nxst/domain/result.hpp>
#include <nxst/domain/title.hpp>
#include <nxst/domain/util.hpp>
#include <nxst/infra/fs/directory.hpp>
#define BUFFER_SIZE 0x80000
namespace io {
nxst::Result<std::string> backup(size_t index, AccountUid uid);
nxst::Result<std::string> restore(size_t index, AccountUid uid, size_t cellIndex, const std::string& nameFromCell);
Result copyDirectory(const std::string& srcPath, const std::string& dstPath);
void copyFile(const std::string& srcPath, const std::string& dstPath);
Result createDirectory(const std::string& path);
Result deleteFolderRecursively(const std::string& path);
bool directoryExists(const std::string& path);
bool fileExists(const std::string& path);
}
nxst::Result<std::string> backup(size_t index, AccountUid uid);
nxst::Result<std::string> restore(size_t index, AccountUid uid, size_t cellIndex,
const std::string& nameFromCell);
Result copyDirectory(const std::string& srcPath, const std::string& dstPath);
void copyFile(const std::string& srcPath, const std::string& dstPath);
Result createDirectory(const std::string& path);
Result deleteFolderRecursively(const std::string& path);
bool directoryExists(const std::string& path);
bool fileExists(const std::string& path);
} // namespace io