rename Bcat -> BCAT, rename bcat folder to BCAT, better impl for stripping leading '/' for zip_add.
This commit is contained in:
@@ -813,7 +813,7 @@ void FsView::ZipFiles(fs::FsPath zip_out) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// root paths are banned in zips, they will warn when extracting otherwise.
|
// root paths are banned in zips, they will warn when extracting otherwise.
|
||||||
if (file_name_in_zip[0] == '/') {
|
while (file_name_in_zip[0] == '/') {
|
||||||
file_name_in_zip++;
|
file_name_in_zip++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -222,9 +222,9 @@ void FakeNacpEntry(ThreadResultData& e) {
|
|||||||
auto GetSaveFolder(u8 data_type) -> fs::FsPath {
|
auto GetSaveFolder(u8 data_type) -> fs::FsPath {
|
||||||
switch (data_type) {
|
switch (data_type) {
|
||||||
case FsSaveDataType_System: return "Save System";
|
case FsSaveDataType_System: return "Save System";
|
||||||
case FsSaveDataType_SystemBcat: return "Save System Bcat";
|
case FsSaveDataType_SystemBcat: return "Save System BCAT";
|
||||||
case FsSaveDataType_Account: return "Save";
|
case FsSaveDataType_Account: return "Save";
|
||||||
case FsSaveDataType_Bcat: return "Save Bcat";
|
case FsSaveDataType_Bcat: return "Save BCAT";
|
||||||
case FsSaveDataType_Device: return "Save Device";
|
case FsSaveDataType_Device: return "Save Device";
|
||||||
case FsSaveDataType_Temporary: return "Save Temporary";
|
case FsSaveDataType_Temporary: return "Save Temporary";
|
||||||
case FsSaveDataType_Cache: return "Save Cache";
|
case FsSaveDataType_Cache: return "Save Cache";
|
||||||
@@ -710,11 +710,11 @@ Menu::Menu(u32 flags) : grid::Menu{"Saves"_i18n, flags} {
|
|||||||
PopupList::Items data_type_items;
|
PopupList::Items data_type_items;
|
||||||
data_type_items.emplace_back("System"_i18n);
|
data_type_items.emplace_back("System"_i18n);
|
||||||
data_type_items.emplace_back("Account"_i18n);
|
data_type_items.emplace_back("Account"_i18n);
|
||||||
data_type_items.emplace_back("Bcat"_i18n);
|
data_type_items.emplace_back("BCAT"_i18n);
|
||||||
data_type_items.emplace_back("Device"_i18n);
|
data_type_items.emplace_back("Device"_i18n);
|
||||||
data_type_items.emplace_back("Temporary"_i18n);
|
data_type_items.emplace_back("Temporary"_i18n);
|
||||||
data_type_items.emplace_back("Cache"_i18n);
|
data_type_items.emplace_back("Cache"_i18n);
|
||||||
data_type_items.emplace_back("SystemBcat"_i18n);
|
data_type_items.emplace_back("System BCAT"_i18n);
|
||||||
|
|
||||||
options->Add(std::make_shared<SidebarEntryCallback>("Sort By"_i18n, [this](){
|
options->Add(std::make_shared<SidebarEntryCallback>("Sort By"_i18n, [this](){
|
||||||
auto options = std::make_shared<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
|
auto options = std::make_shared<Sidebar>("Sort Options"_i18n, Sidebar::Side::RIGHT);
|
||||||
@@ -1391,29 +1391,8 @@ Result Menu::BackupSaveInternal(ProgressBox* pbox, const dump::DumpLocation& loc
|
|||||||
R_UNLESS(ZIP_OK == zipWriteInFileInZip(zfile, &meta, sizeof(meta)), 0x1);
|
R_UNLESS(ZIP_OK == zipWriteInFileInZip(zfile, &meta, sizeof(meta)), 0x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto zip_add = [&](const FsDirectoryEntry& dir_entry, const fs::FsPath& file_path) -> Result {
|
const auto zip_add = [&](const fs::FsPath& file_path) -> Result {
|
||||||
auto zip_info = zip_info_default;
|
const char* file_name_in_zip = file_path.s;
|
||||||
|
|
||||||
// try and load the actual timestamp of the file.
|
|
||||||
// TODO: not supported for saves...
|
|
||||||
#if 1
|
|
||||||
FsTimeStampRaw timestamp{};
|
|
||||||
if (R_SUCCEEDED(save_fs.GetFileTimeStampRaw(file_path, ×tamp)) && timestamp.is_valid) {
|
|
||||||
const auto time = (time_t)timestamp.modified;
|
|
||||||
if (auto tm = localtime(&time)) {
|
|
||||||
zip_info.tmz_date.tm_sec = tm->tm_sec;
|
|
||||||
zip_info.tmz_date.tm_min = tm->tm_min;
|
|
||||||
zip_info.tmz_date.tm_hour = tm->tm_hour;
|
|
||||||
zip_info.tmz_date.tm_mday = tm->tm_mday;
|
|
||||||
zip_info.tmz_date.tm_mon = tm->tm_mon;
|
|
||||||
zip_info.tmz_date.tm_year = tm->tm_year;
|
|
||||||
log_write("got timestamp!\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// the file name needs to be relative to the current directory.
|
|
||||||
const char* file_name_in_zip = file_path.s + std::strlen("/");
|
|
||||||
|
|
||||||
// strip root path (/ or ums0:)
|
// strip root path (/ or ums0:)
|
||||||
if (!std::strncmp(file_name_in_zip, save_fs.Root(), std::strlen(save_fs.Root()))) {
|
if (!std::strncmp(file_name_in_zip, save_fs.Root(), std::strlen(save_fs.Root()))) {
|
||||||
@@ -1421,14 +1400,14 @@ Result Menu::BackupSaveInternal(ProgressBox* pbox, const dump::DumpLocation& loc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// root paths are banned in zips, they will warn when extracting otherwise.
|
// root paths are banned in zips, they will warn when extracting otherwise.
|
||||||
if (file_name_in_zip[0] == '/') {
|
while (file_name_in_zip[0] == '/') {
|
||||||
file_name_in_zip++;
|
file_name_in_zip++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pbox->NewTransfer(file_name_in_zip);
|
pbox->NewTransfer(file_name_in_zip);
|
||||||
|
|
||||||
const auto level = compressed ? Z_DEFAULT_COMPRESSION : Z_NO_COMPRESSION;
|
const auto level = compressed ? Z_DEFAULT_COMPRESSION : Z_NO_COMPRESSION;
|
||||||
if (ZIP_OK != zipOpenNewFileInZip(zfile, file_name_in_zip, &zip_info, NULL, 0, NULL, 0, NULL, Z_DEFLATED, level)) {
|
if (ZIP_OK != zipOpenNewFileInZip(zfile, file_name_in_zip, &zip_info_default, NULL, 0, NULL, 0, NULL, Z_DEFLATED, level)) {
|
||||||
log_write("failed to add zip for %s\n", file_path.s);
|
log_write("failed to add zip for %s\n", file_path.s);
|
||||||
R_THROW(0x1);
|
R_THROW(0x1);
|
||||||
}
|
}
|
||||||
@@ -1441,7 +1420,7 @@ Result Menu::BackupSaveInternal(ProgressBox* pbox, const dump::DumpLocation& loc
|
|||||||
for (const auto& collection : collections) {
|
for (const auto& collection : collections) {
|
||||||
for (const auto& file : collection.files) {
|
for (const auto& file : collection.files) {
|
||||||
const auto file_path = fs::AppendPath(collection.path, file.name);
|
const auto file_path = fs::AppendPath(collection.path, file.name);
|
||||||
R_TRY(zip_add(file, file_path));
|
R_TRY(zip_add(file_path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user