devoptab: only add new entry if mounting is successful.
This commit is contained in:
@@ -235,19 +235,18 @@ Result MountNsp(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& out_path) {
|
||||
}
|
||||
}
|
||||
|
||||
// create new entry.
|
||||
auto& entry = g_entries.emplace_back();
|
||||
|
||||
auto source = std::make_unique<yati::source::File>(fs, path);
|
||||
// R_TRY(yati::container::Xci(source.get()).ReadAll());
|
||||
yati::container::Nsp nsp{source.get()};
|
||||
R_TRY(nsp.GetCollections(entry.device.collections));
|
||||
yati::container::Collections collections;
|
||||
R_TRY(nsp.GetCollections(collections));
|
||||
|
||||
auto& entry = g_entries.emplace_back();
|
||||
entry.path = path;
|
||||
entry.devoptab = DEVOPTAB;
|
||||
entry.devoptab.name = entry.name;
|
||||
entry.devoptab.deviceData = &entry.device;
|
||||
entry.device.source = std::move(source);
|
||||
entry.device.collections = collections;
|
||||
std::snprintf(entry.name, sizeof(entry.name), "nsp_%u", g_mount_idx);
|
||||
std::snprintf(entry.mount, sizeof(entry.mount), "nsp_%u:/", g_mount_idx);
|
||||
|
||||
|
||||
@@ -321,16 +321,14 @@ Result MountFromSavePath(u64 id, fs::FsPath& out_path) {
|
||||
|
||||
log_write("[SAVE] OPEN SUCCESS %s\n", path);
|
||||
|
||||
// create new entry.
|
||||
auto& entry = g_entries.emplace_back();
|
||||
std::snprintf(entry.name, sizeof(entry.name), "%016lx", id);
|
||||
|
||||
entry.id = id;
|
||||
entry.device.ctx = ctx;
|
||||
entry.device.file_table = &ctx->save_filesystem_core.file_table;
|
||||
entry.devoptab = DEVOPTAB;
|
||||
entry.devoptab.name = entry.name;
|
||||
entry.devoptab.deviceData = &entry.device;
|
||||
std::snprintf(entry.name, sizeof(entry.name), "%016lx", id);
|
||||
|
||||
R_UNLESS(AddDevice(&entry.devoptab) >= 0, 0x1);
|
||||
log_write("[SAVE] DEVICE SUCCESS %s %s\n", path, entry.name);
|
||||
|
||||
@@ -255,18 +255,18 @@ Result MountXci(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& out_path) {
|
||||
}
|
||||
}
|
||||
|
||||
// create new entry.
|
||||
auto& entry = g_entries.emplace_back();
|
||||
|
||||
auto source = std::make_unique<yati::source::File>(fs, path);
|
||||
yati::container::Xci xci{source.get()};
|
||||
R_TRY(xci.GetPartitions(entry.device.partitions));
|
||||
yati::container::Xci::Partitions partitions;
|
||||
R_TRY(xci.GetPartitions(partitions));
|
||||
|
||||
auto& entry = g_entries.emplace_back();
|
||||
entry.path = path;
|
||||
entry.devoptab = DEVOPTAB;
|
||||
entry.devoptab.name = entry.name;
|
||||
entry.devoptab.deviceData = &entry.device;
|
||||
entry.device.source = std::move(source);
|
||||
entry.device.partitions = partitions;
|
||||
std::snprintf(entry.name, sizeof(entry.name), "xci_%u", g_mount_idx);
|
||||
std::snprintf(entry.mount, sizeof(entry.mount), "xci_%u:/", g_mount_idx);
|
||||
|
||||
|
||||
@@ -707,7 +707,6 @@ Result MountZip(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& out_path) {
|
||||
}
|
||||
|
||||
// create new entry.
|
||||
auto& entry = g_entries.emplace_back();
|
||||
auto source = std::make_unique<yati::source::File>(fs, path);
|
||||
|
||||
s64 size;
|
||||
@@ -723,6 +722,7 @@ Result MountZip(fs::Fs* fs, const fs::FsPath& path, fs::FsPath& out_path) {
|
||||
DirectoryEntry root;
|
||||
Parse(table_entries, root);
|
||||
|
||||
auto& entry = g_entries.emplace_back();
|
||||
entry.path = path;
|
||||
entry.devoptab = DEVOPTAB;
|
||||
entry.devoptab.name = entry.name;
|
||||
|
||||
Reference in New Issue
Block a user