dc65a4c8a9
Phase 5 — TransferService extraction: - New nxst::TransferService owns all sender/receiver state, threads, and atomics (previously 11 file-statics across transfer_sender.cpp + transfer_receiver.cpp) - startReceive() calls io::restore internally; UI never touches infra/fs or infra/net - TitlesLayout routes all transfer ops through mainApp->transfer - g_currentUId removed from global scope; TitlesLayout::InitTitles(AccountUid) - MainApplication gains transfer member; layout refs renamed to snake_case - userAppExit() updated to cancel via service Phase 6 — Result<T> + RAII: - include/nxst/domain/result.hpp: 85-line tagged-union Result<T,E> + Result<void,E> - include/nxst/infra/fs/handles.hpp: FsFileSystemHandle (auto fsFsClose), FileHandle (auto fclose) — eliminates manual close on every error path - io::backup / io::restore return nxst::Result<std::string> (was tuple<bool,Result,string>) - new u8[] + malloc in copyFile/restore replaced with std::vector<u8> - NACP save-creation extracted to createSaveIfNeeded() helper in io.cpp Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
#pragma once
|
|
#include <cstdio>
|
|
#include <switch.h>
|
|
|
|
namespace nxst {
|
|
|
|
// RAII wrapper for FsFileSystem — auto-closes on destruction.
|
|
struct FsFileSystemHandle {
|
|
FsFileSystem fs{};
|
|
bool valid{false};
|
|
|
|
FsFileSystemHandle() = default;
|
|
~FsFileSystemHandle() { if (valid) fsFsClose(&fs); } // NOLINT(modernize-use-equals-default)
|
|
|
|
FsFileSystemHandle(const FsFileSystemHandle&) = delete;
|
|
FsFileSystemHandle& operator=(const FsFileSystemHandle&) = delete;
|
|
|
|
FsFileSystem* get() { return &fs; }
|
|
|
|
void release() { valid = false; } // transfer ownership to devfs
|
|
};
|
|
|
|
// RAII wrapper for FILE* — auto-fclose on destruction.
|
|
struct FileHandle {
|
|
FILE* ptr{nullptr};
|
|
|
|
explicit FileHandle(FILE* file) : ptr(file) {}
|
|
~FileHandle() { if (ptr != nullptr) fclose(ptr); } // NOLINT(modernize-use-equals-default)
|
|
|
|
FileHandle(const FileHandle&) = delete;
|
|
FileHandle& operator=(const FileHandle&) = delete;
|
|
|
|
explicit operator bool() const { return ptr != nullptr; }
|
|
FILE* get() const { return ptr; }
|
|
};
|
|
|
|
} // namespace nxst
|