mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-06 03:58:02 +08:00
Finish splitting up util.
This commit is contained in:
parent
6c355a0786
commit
52a2dbbf0f
@ -4,7 +4,7 @@
|
||||
#include <3ds.h>
|
||||
|
||||
#include "clipboard.h"
|
||||
#include "util.h"
|
||||
#include "fs.h"
|
||||
|
||||
static bool clipboard_has = false;
|
||||
static bool clipboard_contents_only;
|
||||
@ -32,7 +32,7 @@ Result clipboard_set_contents(FS_Archive archive, const char* path, bool content
|
||||
clipboard_clear();
|
||||
|
||||
Result res = 0;
|
||||
if(R_SUCCEEDED(res = util_ref_archive(archive))) {
|
||||
if(R_SUCCEEDED(res = fs_ref_archive(archive))) {
|
||||
clipboard_has = true;
|
||||
clipboard_contents_only = contentsOnly;
|
||||
|
||||
@ -45,7 +45,7 @@ Result clipboard_set_contents(FS_Archive archive, const char* path, bool content
|
||||
|
||||
void clipboard_clear() {
|
||||
if(clipboard_archive != 0) {
|
||||
util_close_archive(clipboard_archive);
|
||||
fs_close_archive(clipboard_archive);
|
||||
}
|
||||
|
||||
clipboard_has = false;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <3ds.h>
|
||||
|
||||
#include "bnr.h"
|
||||
#include "../util.h"
|
||||
#include "../stringutil.h"
|
||||
|
||||
static CFG_Language region_default_language[] = {
|
||||
CFG_LANGUAGE_JP,
|
||||
@ -21,7 +21,7 @@ u16* bnr_select_title(BNR* bnr) {
|
||||
utf16_to_utf8((uint8_t*) title, bnr->titles[systemLanguage], sizeof(title) - 1);
|
||||
}
|
||||
|
||||
if(util_is_string_empty(title)) {
|
||||
if(string_is_empty(title)) {
|
||||
CFG_Region systemRegion;
|
||||
if(R_SUCCEEDED(CFGU_SecureInfoGetRegion((u8*) &systemRegion))) {
|
||||
systemLanguage = region_default_language[systemRegion];
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <3ds.h>
|
||||
|
||||
#include "smdh.h"
|
||||
#include "../util.h"
|
||||
#include "../stringutil.h"
|
||||
|
||||
#define SMDH_NUM_REGIONS 7
|
||||
#define SMDH_ALL_REGIONS 0x7F
|
||||
@ -60,7 +60,7 @@ SMDH_title* smdh_select_title(SMDH* smdh) {
|
||||
utf16_to_utf8((uint8_t*) shortDescription, smdh->titles[systemLanguage].shortDescription, sizeof(shortDescription) - 1);
|
||||
}
|
||||
|
||||
if(util_is_string_empty(shortDescription)) {
|
||||
if(string_is_empty(shortDescription)) {
|
||||
CFG_Region systemRegion;
|
||||
if(R_SUCCEEDED(CFGU_SecureInfoGetRegion((u8*) &systemRegion))) {
|
||||
systemLanguage = region_default_language[systemRegion];
|
||||
|
@ -4,11 +4,54 @@
|
||||
#include <3ds.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "fs.h"
|
||||
#include "linkedlist.h"
|
||||
#include "util.h"
|
||||
#include "task/task.h"
|
||||
|
||||
FS_Path* util_make_path_utf8(const char* path) {
|
||||
bool fs_is_dir(FS_Archive archive, const char* path) {
|
||||
Result res = 0;
|
||||
|
||||
FS_Path* fsPath = fs_make_path_utf8(path);
|
||||
if(fsPath != NULL) {
|
||||
Handle dirHandle = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenDirectory(&dirHandle, archive, *fsPath))) {
|
||||
FSDIR_Close(dirHandle);
|
||||
}
|
||||
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return R_SUCCEEDED(res);
|
||||
}
|
||||
|
||||
Result fs_ensure_dir(FS_Archive archive, const char* path) {
|
||||
Result res = 0;
|
||||
|
||||
FS_Path* fsPath = fs_make_path_utf8(path);
|
||||
if(fsPath != NULL) {
|
||||
Handle dirHandle = 0;
|
||||
if(R_SUCCEEDED(FSUSER_OpenDirectory(&dirHandle, archive, *fsPath))) {
|
||||
FSDIR_Close(dirHandle);
|
||||
} else {
|
||||
FSUSER_DeleteFile(archive, *fsPath);
|
||||
res = FSUSER_CreateDirectory(archive, *fsPath, 0);
|
||||
}
|
||||
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
FS_Path fs_make_path_binary(const void* data, u32 size) {
|
||||
FS_Path path = {PATH_BINARY, size, data};
|
||||
return path;
|
||||
}
|
||||
|
||||
FS_Path* fs_make_path_utf8(const char* path) {
|
||||
size_t len = strlen(path);
|
||||
|
||||
u16* utf16 = (u16*) calloc(len + 1, sizeof(u16));
|
||||
@ -31,168 +74,11 @@ FS_Path* util_make_path_utf8(const char* path) {
|
||||
return fsPath;
|
||||
}
|
||||
|
||||
void util_free_path_utf8(FS_Path* path) {
|
||||
void fs_free_path_utf8(FS_Path* path) {
|
||||
free((void*) path->data);
|
||||
free(path);
|
||||
}
|
||||
|
||||
FS_Path util_make_binary_path(const void* data, u32 size) {
|
||||
FS_Path path = {PATH_BINARY, size, data};
|
||||
return path;
|
||||
}
|
||||
|
||||
bool util_is_dir(FS_Archive archive, const char* path) {
|
||||
Result res = 0;
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(path);
|
||||
if(fsPath != NULL) {
|
||||
Handle dirHandle = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenDirectory(&dirHandle, archive, *fsPath))) {
|
||||
FSDIR_Close(dirHandle);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return R_SUCCEEDED(res);
|
||||
}
|
||||
|
||||
Result util_ensure_dir(FS_Archive archive, const char* path) {
|
||||
Result res = 0;
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(path);
|
||||
if(fsPath != NULL) {
|
||||
Handle dirHandle = 0;
|
||||
if(R_SUCCEEDED(FSUSER_OpenDirectory(&dirHandle, archive, *fsPath))) {
|
||||
FSDIR_Close(dirHandle);
|
||||
} else {
|
||||
FSUSER_DeleteFile(archive, *fsPath);
|
||||
res = FSUSER_CreateDirectory(archive, *fsPath, 0);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void util_get_file_name(char* out, const char* file, u32 size) {
|
||||
const char* end = file + strlen(file);
|
||||
const char* curr = file - 1;
|
||||
while((curr = strchr(curr + 1, '.')) != NULL) {
|
||||
end = curr;
|
||||
}
|
||||
|
||||
u32 terminatorPos = end - file < size - 1 ? end - file : size - 1;
|
||||
strncpy(out, file, terminatorPos);
|
||||
out[terminatorPos] = '\0';
|
||||
}
|
||||
|
||||
void util_get_path_file(char* out, const char* path, u32 size) {
|
||||
const char* start = NULL;
|
||||
const char* end = NULL;
|
||||
const char* curr = path - 1;
|
||||
while((curr = strchr(curr + 1, '/')) != NULL) {
|
||||
start = end != NULL ? end : path;
|
||||
end = curr;
|
||||
}
|
||||
|
||||
if(end != path + strlen(path) - 1) {
|
||||
start = end;
|
||||
end = path + strlen(path);
|
||||
}
|
||||
|
||||
if(end - start == 0) {
|
||||
strncpy(out, "/", size);
|
||||
} else {
|
||||
u32 terminatorPos = end - start - 1 < size - 1 ? end - start - 1 : size - 1;
|
||||
strncpy(out, start + 1, terminatorPos);
|
||||
out[terminatorPos] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void util_get_parent_path(char* out, const char* path, u32 size) {
|
||||
size_t pathLen = strlen(path);
|
||||
|
||||
const char* start = NULL;
|
||||
const char* end = NULL;
|
||||
const char* curr = path - 1;
|
||||
while((curr = strchr(curr + 1, '/')) != NULL && (start == NULL || curr != path + pathLen - 1)) {
|
||||
start = end != NULL ? end : path;
|
||||
end = curr;
|
||||
}
|
||||
|
||||
u32 terminatorPos = end - path + 1 < size - 1 ? end - path + 1 : size - 1;
|
||||
strncpy(out, path, terminatorPos);
|
||||
out[terminatorPos] = '\0';
|
||||
}
|
||||
|
||||
bool util_is_string_empty(const char* str) {
|
||||
if(strlen(str) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* curr = str;
|
||||
while(*curr) {
|
||||
if(*curr != ' ') {
|
||||
return false;
|
||||
}
|
||||
|
||||
curr++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FS_MediaType util_get_title_destination(u64 titleId) {
|
||||
u16 platform = (u16) ((titleId >> 48) & 0xFFFF);
|
||||
u16 category = (u16) ((titleId >> 32) & 0xFFFF);
|
||||
u8 variation = (u8) (titleId & 0xFF);
|
||||
|
||||
// DSiWare 3DS DSiWare, System, DLP Application System Title
|
||||
return platform == 0x0003 || (platform == 0x0004 && ((category & 0x8011) != 0 || (category == 0x0000 && variation == 0x02))) ? MEDIATYPE_NAND : MEDIATYPE_SD;
|
||||
}
|
||||
|
||||
bool util_filter_cias(void* data, const char* name, u32 attributes) {
|
||||
if((attributes & FS_ATTRIBUTE_DIRECTORY) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t len = strlen(name);
|
||||
return len >= 4 && strncasecmp(name + len - 4, ".cia", 4) == 0;
|
||||
}
|
||||
|
||||
bool util_filter_tickets(void* data, const char* name, u32 attributes) {
|
||||
if((attributes & FS_ATTRIBUTE_DIRECTORY) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t len = strlen(name);
|
||||
return (len >= 4 && strncasecmp(name + len - 4, ".tik", 4) == 0) || (len >= 5 && strncasecmp(name + len - 5, ".cetk", 5) == 0);
|
||||
}
|
||||
|
||||
static char path_3dsx[FILE_PATH_MAX] = {'\0'};
|
||||
|
||||
const char* util_get_3dsx_path() {
|
||||
if(strlen(path_3dsx) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return path_3dsx;
|
||||
}
|
||||
|
||||
void util_set_3dsx_path(const char* path) {
|
||||
if(strlen(path) >= 5 && strncmp(path, "sdmc:", 5) == 0) {
|
||||
strncpy(path_3dsx, path + 5, FILE_PATH_MAX);
|
||||
} else {
|
||||
strncpy(path_3dsx, path, FILE_PATH_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
FS_Archive archive;
|
||||
u32 refs;
|
||||
@ -200,7 +86,7 @@ typedef struct {
|
||||
|
||||
static linked_list opened_archives;
|
||||
|
||||
Result util_open_archive(FS_Archive* archive, FS_ArchiveID id, FS_Path path) {
|
||||
Result fs_open_archive(FS_Archive* archive, FS_ArchiveID id, FS_Path path) {
|
||||
if(archive == NULL) {
|
||||
return R_APP_INVALID_ARGUMENT;
|
||||
}
|
||||
@ -209,7 +95,7 @@ Result util_open_archive(FS_Archive* archive, FS_ArchiveID id, FS_Path path) {
|
||||
|
||||
FS_Archive arch = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenArchive(&arch, id, path))) {
|
||||
if(R_SUCCEEDED(res = util_ref_archive(arch))) {
|
||||
if(R_SUCCEEDED(res = fs_ref_archive(arch))) {
|
||||
*archive = arch;
|
||||
} else {
|
||||
FSUSER_CloseArchive(arch);
|
||||
@ -219,7 +105,7 @@ Result util_open_archive(FS_Archive* archive, FS_ArchiveID id, FS_Path path) {
|
||||
return res;
|
||||
}
|
||||
|
||||
Result util_ref_archive(FS_Archive archive) {
|
||||
Result fs_ref_archive(FS_Archive archive) {
|
||||
linked_list_iter iter;
|
||||
linked_list_iterate(&opened_archives, &iter);
|
||||
|
||||
@ -246,7 +132,7 @@ Result util_ref_archive(FS_Archive archive) {
|
||||
return res;
|
||||
}
|
||||
|
||||
Result util_close_archive(FS_Archive archive) {
|
||||
Result fs_close_archive(FS_Archive archive) {
|
||||
linked_list_iter iter;
|
||||
linked_list_iterate(&opened_archives, &iter);
|
||||
|
||||
@ -267,26 +153,47 @@ Result util_close_archive(FS_Archive archive) {
|
||||
return FSUSER_CloseArchive(archive);
|
||||
}
|
||||
|
||||
void util_escape_file_name(char* out, const char* file, size_t size) {
|
||||
static const char reservedChars[] = {'<', '>', ':', '"', '/', '\\', '|', '?', '*'};
|
||||
static char path_3dsx[FILE_PATH_MAX] = {'\0'};
|
||||
|
||||
for(u32 i = 0; i < size; i++) {
|
||||
bool reserved = false;
|
||||
for(u32 j = 0; j < sizeof(reservedChars); j++) {
|
||||
if(file[i] == reservedChars[j]) {
|
||||
reserved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const char* fs_get_3dsx_path() {
|
||||
if(strlen(path_3dsx) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(reserved) {
|
||||
out[i] = '_';
|
||||
} else {
|
||||
out[i] = file[i];
|
||||
}
|
||||
return path_3dsx;
|
||||
}
|
||||
|
||||
if(file[i] == '\0') {
|
||||
break;
|
||||
}
|
||||
void fs_set_3dsx_path(const char* path) {
|
||||
if(strlen(path) >= 5 && strncmp(path, "sdmc:", 5) == 0) {
|
||||
strncpy(path_3dsx, path + 5, FILE_PATH_MAX);
|
||||
} else {
|
||||
strncpy(path_3dsx, path, FILE_PATH_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
FS_MediaType fs_get_title_destination(u64 titleId) {
|
||||
u16 platform = (u16) ((titleId >> 48) & 0xFFFF);
|
||||
u16 category = (u16) ((titleId >> 32) & 0xFFFF);
|
||||
u8 variation = (u8) (titleId & 0xFF);
|
||||
|
||||
// DSiWare 3DS DSiWare, System, DLP Application System Title
|
||||
return platform == 0x0003 || (platform == 0x0004 && ((category & 0x8011) != 0 || (category == 0x0000 && variation == 0x02))) ? MEDIATYPE_NAND : MEDIATYPE_SD;
|
||||
}
|
||||
|
||||
bool fs_filter_cias(void* data, const char* name, u32 attributes) {
|
||||
if((attributes & FS_ATTRIBUTE_DIRECTORY) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t len = strlen(name);
|
||||
return len >= 4 && strncasecmp(name + len - 4, ".cia", 4) == 0;
|
||||
}
|
||||
|
||||
bool fs_filter_tickets(void* data, const char* name, u32 attributes) {
|
||||
if((attributes & FS_ATTRIBUTE_DIRECTORY) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t len = strlen(name);
|
||||
return (len >= 4 && strncasecmp(name + len - 4, ".tik", 4) == 0) || (len >= 5 && strncasecmp(name + len - 5, ".cetk", 5) == 0);
|
||||
}
|
23
source/core/fs.h
Normal file
23
source/core/fs.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#define FILE_NAME_MAX 512
|
||||
#define FILE_PATH_MAX 512
|
||||
|
||||
bool fs_is_dir(FS_Archive archive, const char* path);
|
||||
Result fs_ensure_dir(FS_Archive archive, const char* path);
|
||||
|
||||
FS_Path fs_make_path_binary(const void* data, u32 size);
|
||||
FS_Path* fs_make_path_utf8(const char* path);
|
||||
void fs_free_path_utf8(FS_Path* path);
|
||||
|
||||
Result fs_open_archive(FS_Archive* archive, FS_ArchiveID id, FS_Path path);
|
||||
Result fs_ref_archive(FS_Archive archive);
|
||||
Result fs_close_archive(FS_Archive archive);
|
||||
|
||||
const char* fs_get_3dsx_path();
|
||||
void fs_set_3dsx_path(const char* path);
|
||||
|
||||
FS_MediaType fs_get_title_destination(u64 titleId);
|
||||
|
||||
bool fs_filter_cias(void* data, const char* name, u32 attributes);
|
||||
bool fs_filter_tickets(void* data, const char* name, u32 attributes);
|
97
source/core/stringutil.c
Normal file
97
source/core/stringutil.c
Normal file
@ -0,0 +1,97 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#include "stringutil.h"
|
||||
|
||||
bool string_is_empty(const char* str) {
|
||||
if(strlen(str) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* curr = str;
|
||||
while(*curr) {
|
||||
if(*curr != ' ') {
|
||||
return false;
|
||||
}
|
||||
|
||||
curr++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void string_get_file_name(char* out, const char* file, u32 size) {
|
||||
const char* end = file + strlen(file);
|
||||
const char* curr = file - 1;
|
||||
while((curr = strchr(curr + 1, '.')) != NULL) {
|
||||
end = curr;
|
||||
}
|
||||
|
||||
u32 terminatorPos = end - file < size - 1 ? end - file : size - 1;
|
||||
strncpy(out, file, terminatorPos);
|
||||
out[terminatorPos] = '\0';
|
||||
}
|
||||
|
||||
void string_escape_file_name(char* out, const char* file, size_t size) {
|
||||
static const char reservedChars[] = {'<', '>', ':', '"', '/', '\\', '|', '?', '*'};
|
||||
|
||||
for(u32 i = 0; i < size; i++) {
|
||||
bool reserved = false;
|
||||
for(u32 j = 0; j < sizeof(reservedChars); j++) {
|
||||
if(file[i] == reservedChars[j]) {
|
||||
reserved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(reserved) {
|
||||
out[i] = '_';
|
||||
} else {
|
||||
out[i] = file[i];
|
||||
}
|
||||
|
||||
if(file[i] == '\0') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void string_get_path_file(char* out, const char* path, u32 size) {
|
||||
const char* start = NULL;
|
||||
const char* end = NULL;
|
||||
const char* curr = path - 1;
|
||||
while((curr = strchr(curr + 1, '/')) != NULL) {
|
||||
start = end != NULL ? end : path;
|
||||
end = curr;
|
||||
}
|
||||
|
||||
if(end != path + strlen(path) - 1) {
|
||||
start = end;
|
||||
end = path + strlen(path);
|
||||
}
|
||||
|
||||
if(end - start == 0) {
|
||||
strncpy(out, "/", size);
|
||||
} else {
|
||||
u32 terminatorPos = end - start - 1 < size - 1 ? end - start - 1 : size - 1;
|
||||
strncpy(out, start + 1, terminatorPos);
|
||||
out[terminatorPos] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void string_get_parent_path(char* out, const char* path, u32 size) {
|
||||
size_t pathLen = strlen(path);
|
||||
|
||||
const char* start = NULL;
|
||||
const char* end = NULL;
|
||||
const char* curr = path - 1;
|
||||
while((curr = strchr(curr + 1, '/')) != NULL && (start == NULL || curr != path + pathLen - 1)) {
|
||||
start = end != NULL ? end : path;
|
||||
end = curr;
|
||||
}
|
||||
|
||||
u32 terminatorPos = end - path + 1 < size - 1 ? end - path + 1 : size - 1;
|
||||
strncpy(out, path, terminatorPos);
|
||||
out[terminatorPos] = '\0';
|
||||
}
|
8
source/core/stringutil.h
Normal file
8
source/core/stringutil.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
bool string_is_empty(const char* str);
|
||||
|
||||
void string_get_file_name(char* out, const char* file, u32 size);
|
||||
void string_escape_file_name(char* out, const char* file, size_t size);
|
||||
void string_get_path_file(char* out, const char* path, u32 size);
|
||||
void string_get_parent_path(char* out, const char* path, u32 size);
|
@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct json_t json_t;
|
||||
|
||||
// File constants
|
||||
#define FILE_NAME_MAX 512
|
||||
#define FILE_PATH_MAX 512
|
||||
|
||||
// Strings
|
||||
bool util_is_string_empty(const char* str);
|
||||
|
||||
// Paths
|
||||
const char* util_get_3dsx_path();
|
||||
void util_set_3dsx_path(const char* path);
|
||||
|
||||
void util_get_file_name(char* out, const char* file, u32 size);
|
||||
void util_escape_file_name(char* out, const char* file, size_t size);
|
||||
void util_get_path_file(char* out, const char* path, u32 size);
|
||||
void util_get_parent_path(char* out, const char* path, u32 size);
|
||||
|
||||
bool util_filter_cias(void* data, const char* name, u32 attributes);
|
||||
bool util_filter_tickets(void* data, const char* name, u32 attributes);
|
||||
|
||||
// Files
|
||||
Result util_open_archive(FS_Archive* archive, FS_ArchiveID id, FS_Path path);
|
||||
Result util_ref_archive(FS_Archive archive);
|
||||
Result util_close_archive(FS_Archive archive);
|
||||
|
||||
FS_Path util_make_binary_path(const void* data, u32 size);
|
||||
FS_Path* util_make_path_utf8(const char* path);
|
||||
void util_free_path_utf8(FS_Path* path);
|
||||
|
||||
bool util_is_dir(FS_Archive archive, const char* path);
|
||||
Result util_ensure_dir(FS_Archive archive, const char* path);
|
||||
|
||||
// Titles
|
||||
FS_MediaType util_get_title_destination(u64 titleId);
|
@ -6,8 +6,8 @@
|
||||
|
||||
#include "core/clipboard.h"
|
||||
#include "core/error.h"
|
||||
#include "core/fs.h"
|
||||
#include "core/screen.h"
|
||||
#include "core/util.h"
|
||||
#include "core/task/task.h"
|
||||
#include "ui/mainmenu.h"
|
||||
#include "ui/ui.h"
|
||||
@ -177,7 +177,7 @@ void cleanup() {
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
if(argc > 0 && envIsHomebrew()) {
|
||||
util_set_3dsx_path(argv[0]);
|
||||
fs_set_3dsx_path(argv[0]);
|
||||
}
|
||||
|
||||
init();
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#include "resources.h"
|
||||
#include "../core/error.h"
|
||||
#include "../core/fs.h"
|
||||
#include "../core/screen.h"
|
||||
#include "../core/util.h"
|
||||
#include "../core/task/task.h"
|
||||
|
||||
static FILE* resources_open_file(const char* path) {
|
||||
|
@ -4,11 +4,11 @@
|
||||
#include "../section.h"
|
||||
#include "../task/uitask.h"
|
||||
#include "../../list.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/fs.h"
|
||||
|
||||
void action_browse_boss_ext_save_data(linked_list* items, list_item* selected) {
|
||||
ext_save_data_info* info = (ext_save_data_info*) selected->data;
|
||||
|
||||
u32 path[3] = {info->mediaType, (u32) (info->extSaveDataId & 0xFFFFFFFF), (u32) ((info->extSaveDataId >> 32) & 0xFFFFFFFF)};
|
||||
files_open(ARCHIVE_BOSS_EXTDATA, util_make_binary_path(path, sizeof(path)));
|
||||
files_open(ARCHIVE_BOSS_EXTDATA, fs_make_path_binary(path, sizeof(path)));
|
||||
}
|
@ -4,11 +4,11 @@
|
||||
#include "../section.h"
|
||||
#include "../task/uitask.h"
|
||||
#include "../../list.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/fs.h"
|
||||
|
||||
void action_browse_system_save_data(linked_list* items, list_item* selected) {
|
||||
system_save_data_info* info = (system_save_data_info*) selected->data;
|
||||
|
||||
u32 path[2] = {MEDIATYPE_NAND, info->systemSaveDataId};
|
||||
files_open(ARCHIVE_SYSTEM_SAVEDATA, util_make_binary_path(path, sizeof(path)));
|
||||
files_open(ARCHIVE_SYSTEM_SAVEDATA, fs_make_path_binary(path, sizeof(path)));
|
||||
}
|
@ -4,11 +4,11 @@
|
||||
#include "../section.h"
|
||||
#include "../task/uitask.h"
|
||||
#include "../../list.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/fs.h"
|
||||
|
||||
void action_browse_title_save_data(linked_list* items, list_item* selected) {
|
||||
title_info* info = (title_info*) selected->data;
|
||||
|
||||
u32 path[3] = {info->mediaType, (u32) (info->titleId & 0xFFFFFFFF), (u32) ((info->titleId >> 32) & 0xFFFFFFFF)};
|
||||
files_open(ARCHIVE_USER_SAVEDATA, util_make_binary_path(path, sizeof(path)));
|
||||
files_open(ARCHIVE_USER_SAVEDATA, fs_make_path_binary(path, sizeof(path)));
|
||||
}
|
@ -4,11 +4,11 @@
|
||||
#include "../section.h"
|
||||
#include "../task/uitask.h"
|
||||
#include "../../list.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/fs.h"
|
||||
|
||||
void action_browse_user_ext_save_data(linked_list* items, list_item* selected) {
|
||||
ext_save_data_info* info = (ext_save_data_info*) selected->data;
|
||||
|
||||
u32 path[3] = {info->mediaType, (u32) (info->extSaveDataId & 0xFFFFFFFF), (u32) ((info->extSaveDataId >> 32) & 0xFFFFFFFF)};
|
||||
files_open(info->shared ? ARCHIVE_SHARED_EXTDATA : ARCHIVE_EXTDATA, util_make_binary_path(path, sizeof(path)));
|
||||
files_open(info->shared ? ARCHIVE_SHARED_EXTDATA : ARCHIVE_EXTDATA, fs_make_path_binary(path, sizeof(path)));
|
||||
}
|
@ -13,9 +13,9 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
|
||||
typedef struct {
|
||||
linked_list* items;
|
||||
@ -46,15 +46,15 @@ static Result action_delete_delete(void* data, u32 index) {
|
||||
|
||||
file_info* info = (file_info*) ((list_item*) linked_list_get(&deleteData->contents, linked_list_size(&deleteData->contents) - index - 1))->data;
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(info->path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(info->path);
|
||||
if(fsPath != NULL) {
|
||||
if(util_is_dir(deleteData->target->archive, info->path)) {
|
||||
if(fs_is_dir(deleteData->target->archive, info->path)) {
|
||||
res = FSUSER_DeleteDirectory(deleteData->target->archive, *fsPath);
|
||||
} else {
|
||||
res = FSUSER_DeleteFile(deleteData->target->archive, *fsPath);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -239,7 +239,7 @@ static void action_delete_internal(linked_list* items, list_item* selected, cons
|
||||
strncpy(loadingData->popData.path, data->target->path, FILE_PATH_MAX);
|
||||
loadingData->popData.recursive = recursive;
|
||||
loadingData->popData.includeBase = includeBase;
|
||||
loadingData->popData.filter = ciasOnly ? util_filter_cias : ticketsOnly ? util_filter_tickets : NULL;
|
||||
loadingData->popData.filter = ciasOnly ? fs_filter_cias : ticketsOnly ? fs_filter_tickets : NULL;
|
||||
loadingData->popData.filterData = NULL;
|
||||
|
||||
Result listRes = task_populate_files(&loadingData->popData);
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/spi.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
|
||||
typedef struct {
|
||||
title_info* title;
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
|
||||
static void action_export_secure_value_update(ui_view* view, void* data, float* progress, char* text) {
|
||||
title_info* info = (title_info*) data;
|
||||
@ -34,11 +34,11 @@ static void action_export_secure_value_update(ui_view* view, void* data, float*
|
||||
|
||||
FS_Archive sdmcArchive = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")))) {
|
||||
if(R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, "/fbi/")) && R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, "/fbi/securevalue/"))) {
|
||||
if(R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, "/fbi/")) && R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, "/fbi/securevalue/"))) {
|
||||
char pathBuf[64];
|
||||
snprintf(pathBuf, 64, "/fbi/securevalue/%016llX.dat", info->titleId);
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(pathBuf);
|
||||
FS_Path* fsPath = fs_make_path_utf8(pathBuf);
|
||||
if(fsPath != NULL) {
|
||||
Handle fileHandle = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenFile(&fileHandle, sdmcArchive, *fsPath, FS_OPEN_WRITE | FS_OPEN_CREATE, 0))) {
|
||||
@ -47,7 +47,7 @@ static void action_export_secure_value_update(ui_view* view, void* data, float*
|
||||
FSFILE_Close(fileHandle);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -12,10 +12,11 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/spi.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
|
||||
typedef struct {
|
||||
title_info* title;
|
||||
@ -66,18 +67,18 @@ static Result action_export_twl_save_open_dst(void* data, u32 index, void* initi
|
||||
|
||||
FS_Archive sdmcArchive = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")))) {
|
||||
if(R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, "/fbi/")) && R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, "/fbi/save/"))) {
|
||||
if(R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, "/fbi/")) && R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, "/fbi/save/"))) {
|
||||
char gameName[0x10] = {'\0'};
|
||||
util_escape_file_name(gameName, exportData->title->productCode, sizeof(gameName));
|
||||
string_escape_file_name(gameName, exportData->title->productCode, sizeof(gameName));
|
||||
|
||||
char path[FILE_PATH_MAX];
|
||||
snprintf(path, sizeof(path), "/fbi/save/%s.sav", gameName);
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(path);
|
||||
if(fsPath != NULL) {
|
||||
res = FSUSER_OpenFileDirectly(handle, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""), *fsPath, FS_OPEN_WRITE | FS_OPEN_CREATE, 0);
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -12,9 +12,9 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/data/smdh.h"
|
||||
|
||||
static void action_extract_smdh_update(ui_view* view, void* data, float* progress, char* text) {
|
||||
@ -26,18 +26,20 @@ static void action_extract_smdh_update(ui_view* view, void* data, float* progres
|
||||
u32 archivePath[4] = {(u32) (info->titleId & 0xFFFFFFFF), (u32) ((info->titleId >> 32) & 0xFFFFFFFF), info->mediaType, 0x00000000};
|
||||
|
||||
Handle fileHandle;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenFileDirectly(&fileHandle, ARCHIVE_SAVEDATA_AND_CONTENT, util_make_binary_path(archivePath, sizeof(archivePath)), util_make_binary_path(filePath, sizeof(filePath)), FS_OPEN_READ, 0))) {
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenFileDirectly(&fileHandle, ARCHIVE_SAVEDATA_AND_CONTENT,
|
||||
fs_make_path_binary(archivePath, sizeof(archivePath)),
|
||||
fs_make_path_binary(filePath, sizeof(filePath)), FS_OPEN_READ, 0))) {
|
||||
SMDH* smdh = (SMDH*) calloc(1, sizeof(SMDH));
|
||||
if(smdh != NULL) {
|
||||
u32 bytesRead = 0;
|
||||
if(R_SUCCEEDED(res = FSFILE_Read(fileHandle, &bytesRead, 0, smdh, sizeof(SMDH))) && bytesRead == sizeof(SMDH)) {
|
||||
FS_Archive sdmcArchive = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")))) {
|
||||
if(R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, "/fbi/")) && R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, "/fbi/smdh/"))) {
|
||||
if(R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, "/fbi/")) && R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, "/fbi/smdh/"))) {
|
||||
char pathBuf[64];
|
||||
snprintf(pathBuf, 64, "/fbi/smdh/%016llX.smdh", info->titleId);
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(pathBuf);
|
||||
FS_Path* fsPath = fs_make_path_utf8(pathBuf);
|
||||
if(fsPath != NULL) {
|
||||
Handle smdhHandle = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenFile(&smdhHandle, sdmcArchive, *fsPath, FS_OPEN_WRITE | FS_OPEN_CREATE, 0))) {
|
||||
@ -46,7 +48,7 @@ static void action_extract_smdh_update(ui_view* view, void* data, float* progres
|
||||
FSFILE_Close(smdhHandle);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
|
||||
static void action_import_secure_value_update(ui_view* view, void* data, float* progress, char* text) {
|
||||
title_info* info = (title_info*) data;
|
||||
@ -23,7 +23,7 @@ static void action_import_secure_value_update(ui_view* view, void* data, float*
|
||||
|
||||
Result res = 0;
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(pathBuf);
|
||||
FS_Path* fsPath = fs_make_path_utf8(pathBuf);
|
||||
if(fsPath != NULL) {
|
||||
Handle fileHandle = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenFileDirectly(&fileHandle, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""), *fsPath, FS_OPEN_READ, 0))) {
|
||||
@ -36,7 +36,7 @@ static void action_import_secure_value_update(ui_view* view, void* data, float*
|
||||
FSFILE_Close(fileHandle);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
|
||||
static void action_import_seed_update(ui_view* view, void* data, float* progress, char* text) {
|
||||
title_info* info = (title_info*) data;
|
||||
|
@ -12,10 +12,11 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/spi.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
|
||||
typedef struct {
|
||||
title_info* title;
|
||||
@ -42,16 +43,16 @@ static Result action_import_twl_save_open_src(void* data, u32 index, u32* handle
|
||||
Result res = 0;
|
||||
|
||||
char gameName[0x10] = {'\0'};
|
||||
util_escape_file_name(gameName, importData->title->productCode, sizeof(gameName));
|
||||
string_escape_file_name(gameName, importData->title->productCode, sizeof(gameName));
|
||||
|
||||
char path[FILE_PATH_MAX];
|
||||
snprintf(path, sizeof(path), "/fbi/save/%s.sav", gameName);
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(path);
|
||||
if(fsPath != NULL) {
|
||||
res = FSUSER_OpenFileDirectly(handle, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""), *fsPath, FS_OPEN_READ, 0);
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -14,10 +14,10 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/http.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/data/tmd.h"
|
||||
|
||||
#define CONTENTS_MAX 256
|
||||
@ -124,7 +124,7 @@ static Result action_install_cdn_close_dst(void* data, u32 index, bool succeeded
|
||||
} else {
|
||||
Result res = 0;
|
||||
if(R_SUCCEEDED(res = AM_InstallContentFinish(handle)) && index == 1 && installData->contentCount > 1 && (installData->ticket->titleId >> 32) == 0x0004008C) {
|
||||
FS_MediaType dest = util_get_title_destination(installData->ticket->titleId);
|
||||
FS_MediaType dest = fs_get_title_destination(installData->ticket->titleId);
|
||||
if(R_SUCCEEDED(res = AM_InstallTitleFinish())
|
||||
&& R_SUCCEEDED(res = AM_CommitImportTitles(dest, 1, false, &installData->ticket->titleId))
|
||||
&& R_SUCCEEDED(res = AM_InstallTitleBegin(dest, installData->ticket->titleId, false))) {
|
||||
@ -172,7 +172,7 @@ static Result action_install_cdn_suspend(void* data, u32 index) {
|
||||
static Result action_install_cdn_restore(void* data, u32 index) {
|
||||
install_cdn_data* installData = (install_cdn_data*) data;
|
||||
|
||||
return AM_InstallTitleResume(util_get_title_destination(installData->ticket->titleId), installData->ticket->titleId);
|
||||
return AM_InstallTitleResume(fs_get_title_destination(installData->ticket->titleId), installData->ticket->titleId);
|
||||
}
|
||||
|
||||
bool action_install_cdn_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||
@ -206,7 +206,7 @@ static void action_install_cdn_update(ui_view* view, void* data, float* progress
|
||||
|
||||
if(R_SUCCEEDED(installData->installInfo.result)) {
|
||||
if(R_SUCCEEDED(res = AM_InstallTitleFinish())
|
||||
&& R_SUCCEEDED(res = AM_CommitImportTitles(util_get_title_destination(installData->ticket->titleId), 1, false, &installData->ticket->titleId))) {
|
||||
&& R_SUCCEEDED(res = AM_CommitImportTitles(fs_get_title_destination(installData->ticket->titleId), 1, false, &installData->ticket->titleId))) {
|
||||
task_download_seed_sync(installData->ticket->titleId);
|
||||
|
||||
if(installData->ticket->titleId == 0x0004013800000002 || installData->ticket->titleId == 0x0004013820000002) {
|
||||
@ -255,7 +255,7 @@ static void action_install_cdn_n3ds_onresponse(ui_view* view, void* data, u32 re
|
||||
install_cdn_data* installData = (install_cdn_data*) data;
|
||||
|
||||
if(response == PROMPT_YES) {
|
||||
FS_MediaType dest = util_get_title_destination(installData->ticket->titleId);
|
||||
FS_MediaType dest = fs_get_title_destination(installData->ticket->titleId);
|
||||
|
||||
AM_DeleteTitle(dest, installData->ticket->titleId);
|
||||
if(dest == MEDIATYPE_SD) {
|
||||
|
@ -13,9 +13,9 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
|
||||
typedef struct {
|
||||
linked_list* items;
|
||||
@ -63,11 +63,11 @@ static Result action_install_cias_open_src(void* data, u32 index, u32* handle) {
|
||||
|
||||
Result res = 0;
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(info->path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(info->path);
|
||||
if(fsPath != NULL) {
|
||||
res = FSUSER_OpenFile(handle, info->archive, *fsPath, FS_OPEN_READ, 0);
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -83,7 +83,7 @@ static Result action_install_cias_close_src(void* data, u32 index, bool succeede
|
||||
Result res = 0;
|
||||
|
||||
if(R_SUCCEEDED(res = FSFILE_Close(handle)) && installData->delete && succeeded) {
|
||||
FS_Path* fsPath = util_make_path_utf8(info->path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(info->path);
|
||||
if(fsPath != NULL) {
|
||||
if(R_SUCCEEDED(FSUSER_DeleteFile(info->archive, *fsPath))) {
|
||||
linked_list_iter iter;
|
||||
@ -100,7 +100,7 @@ static Result action_install_cias_close_src(void* data, u32 index, bool succeede
|
||||
}
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -124,7 +124,7 @@ static Result action_install_cias_open_dst(void* data, u32 index, void* initialR
|
||||
|
||||
file_info* info = (file_info*) ((list_item*) linked_list_get(&installData->contents, index))->data;
|
||||
|
||||
FS_MediaType dest = util_get_title_destination(info->ciaInfo.titleId);
|
||||
FS_MediaType dest = fs_get_title_destination(info->ciaInfo.titleId);
|
||||
|
||||
bool n3ds = false;
|
||||
if(R_SUCCEEDED(APT_CheckNew3DS(&n3ds)) && !n3ds && ((info->ciaInfo.titleId >> 28) & 0xF) == 2) {
|
||||
@ -378,7 +378,7 @@ static void action_install_cias_internal(linked_list* items, list_item* selected
|
||||
strncpy(loadingData->popData.path, data->target->path, FILE_PATH_MAX);
|
||||
loadingData->popData.recursive = false;
|
||||
loadingData->popData.includeBase = !(data->target->attributes & FS_ATTRIBUTE_DIRECTORY);
|
||||
loadingData->popData.filter = util_filter_cias;
|
||||
loadingData->popData.filter = fs_filter_cias;
|
||||
loadingData->popData.filterData = NULL;
|
||||
|
||||
Result listRes = task_populate_files(&loadingData->popData);
|
||||
|
@ -13,9 +13,9 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
|
||||
typedef struct {
|
||||
linked_list* items;
|
||||
@ -59,11 +59,11 @@ static Result action_install_tickets_open_src(void* data, u32 index, u32* handle
|
||||
|
||||
Result res = 0;
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(info->path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(info->path);
|
||||
if(fsPath != NULL) {
|
||||
res = FSUSER_OpenFile(handle, info->archive, *fsPath, FS_OPEN_READ, 0);
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -79,7 +79,7 @@ static Result action_install_tickets_close_src(void* data, u32 index, bool succe
|
||||
Result res = 0;
|
||||
|
||||
if(R_SUCCEEDED(res = FSFILE_Close(handle)) && installData->delete && succeeded) {
|
||||
FS_Path* fsPath = util_make_path_utf8(info->path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(info->path);
|
||||
if(fsPath != NULL) {
|
||||
if(R_SUCCEEDED(FSUSER_DeleteFile(info->archive, *fsPath))) {
|
||||
linked_list_iter iter;
|
||||
@ -96,7 +96,7 @@ static Result action_install_tickets_close_src(void* data, u32 index, bool succe
|
||||
}
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -352,7 +352,7 @@ static void action_install_tickets_internal(linked_list* items, list_item* selec
|
||||
strncpy(loadingData->popData.path, data->target->path, FILE_PATH_MAX);
|
||||
loadingData->popData.recursive = false;
|
||||
loadingData->popData.includeBase = !(data->target->attributes & FS_ATTRIBUTE_DIRECTORY);
|
||||
loadingData->popData.filter = util_filter_tickets;
|
||||
loadingData->popData.filter = fs_filter_tickets;
|
||||
loadingData->popData.filterData = NULL;
|
||||
|
||||
Result listRes = task_populate_files(&loadingData->popData);
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "../../list.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
|
||||
typedef struct {
|
||||
list_item* selected;
|
||||
@ -53,7 +53,7 @@ void action_install_titledb(linked_list* items, list_item* selected, bool cia) {
|
||||
snprintf(url, DOWNLOAD_URL_MAX, "https://3ds.titledb.com/v1/tdsx/%lu/download", info->tdsx.id);
|
||||
|
||||
char name[FILE_NAME_MAX];
|
||||
util_escape_file_name(name, info->meta.shortDescription, sizeof(name));
|
||||
string_escape_file_name(name, info->meta.shortDescription, sizeof(name));
|
||||
snprintf(path3dsx, sizeof(path3dsx), "/3ds/%s/%s.3dsx", name, name);
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,10 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/http.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
#include "../../../core/data/cia.h"
|
||||
#include "../../../core/data/ticket.h"
|
||||
|
||||
@ -166,7 +167,7 @@ static Result action_install_url_open_dst(void* data, u32 index, void* initialRe
|
||||
|
||||
u64 titleId = cia_get_title_id((u8*) initialReadBlock);
|
||||
|
||||
FS_MediaType dest = util_get_title_destination(titleId);
|
||||
FS_MediaType dest = fs_get_title_destination(titleId);
|
||||
|
||||
bool n3ds = false;
|
||||
if(R_SUCCEEDED(APT_CheckNew3DS(&n3ds)) && !n3ds && ((titleId >> 28) & 0xF) == 2) {
|
||||
@ -220,27 +221,27 @@ static Result action_install_url_open_dst(void* data, u32 index, void* initialRe
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")))) {
|
||||
char dir[FILE_PATH_MAX];
|
||||
if(strlen(installData->path3dsx) > 0) {
|
||||
util_get_parent_path(dir, installData->path3dsx, FILE_PATH_MAX);
|
||||
string_get_parent_path(dir, installData->path3dsx, FILE_PATH_MAX);
|
||||
strncpy(installData->curr3dsxPath, installData->path3dsx, FILE_PATH_MAX);
|
||||
} else {
|
||||
char filename[FILE_NAME_MAX];
|
||||
if(R_FAILED(http_get_file_name(installData->currContext, filename, FILE_NAME_MAX))) {
|
||||
util_get_path_file(filename, installData->urls[index], FILE_NAME_MAX);
|
||||
string_get_path_file(filename, installData->urls[index], FILE_NAME_MAX);
|
||||
}
|
||||
|
||||
char name[FILE_NAME_MAX];
|
||||
util_get_file_name(name, filename, FILE_NAME_MAX);
|
||||
string_get_file_name(name, filename, FILE_NAME_MAX);
|
||||
|
||||
snprintf(dir, FILE_PATH_MAX, "/3ds/%s/", name);
|
||||
snprintf(installData->curr3dsxPath, FILE_PATH_MAX, "/3ds/%s/%s.3dsx", name, name);
|
||||
}
|
||||
|
||||
if(R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, "/3ds/")) && R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, dir))) {
|
||||
FS_Path* path = util_make_path_utf8(installData->curr3dsxPath);
|
||||
if(R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, "/3ds/")) && R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, dir))) {
|
||||
FS_Path* path = fs_make_path_utf8(installData->curr3dsxPath);
|
||||
if(path != NULL) {
|
||||
res = FSUSER_OpenFileDirectly(handle, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""), *path, FS_OPEN_WRITE | FS_OPEN_CREATE, 0);
|
||||
|
||||
util_free_path_utf8(path);
|
||||
fs_free_path_utf8(path);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -293,11 +294,11 @@ static Result action_install_url_close_dst(void* data, u32 index, bool succeeded
|
||||
|
||||
FS_Archive sdmcArchive = 0;
|
||||
if(R_SUCCEEDED(FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")))) {
|
||||
FS_Path* path = util_make_path_utf8(installData->curr3dsxPath);
|
||||
FS_Path* path = fs_make_path_utf8(installData->curr3dsxPath);
|
||||
if(path != NULL) {
|
||||
FSUSER_DeleteFile(sdmcArchive, *path);
|
||||
|
||||
util_free_path_utf8(path);
|
||||
fs_free_path_utf8(path);
|
||||
}
|
||||
|
||||
FSUSER_CloseArchive(sdmcArchive);
|
||||
|
@ -13,9 +13,10 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
|
||||
typedef struct {
|
||||
linked_list* items;
|
||||
@ -31,16 +32,16 @@ static void action_new_folder_onresponse(ui_view* view, void* data, SwkbdButton
|
||||
file_info* parentDir = (file_info*) newFolderData->selected->data;
|
||||
|
||||
char fileName[FILE_NAME_MAX] = {'\0'};
|
||||
util_escape_file_name(fileName, response, sizeof(fileName));
|
||||
string_escape_file_name(fileName, response, sizeof(fileName));
|
||||
|
||||
char path[FILE_PATH_MAX] = {'\0'};
|
||||
snprintf(path, FILE_PATH_MAX, "%s%s", parentDir->path, fileName);
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(path);
|
||||
if(fsPath != NULL) {
|
||||
res = FSUSER_CreateDirectory(parentDir->archive, *fsPath, FS_ATTRIBUTE_DIRECTORY);
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -13,10 +13,11 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/clipboard.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
|
||||
typedef struct {
|
||||
linked_list* items;
|
||||
@ -45,14 +46,14 @@ static void action_paste_contents_get_dst_path(paste_contents_data* data, u32 in
|
||||
if(clipboard_is_contents_only()) {
|
||||
strncpy(baseSrcPath, clipboard_get_path(), FILE_PATH_MAX);
|
||||
} else {
|
||||
util_get_parent_path(baseSrcPath, clipboard_get_path(), FILE_PATH_MAX);
|
||||
string_get_parent_path(baseSrcPath, clipboard_get_path(), FILE_PATH_MAX);
|
||||
}
|
||||
|
||||
char baseDstPath[FILE_PATH_MAX];
|
||||
if(data->target->attributes & FS_ATTRIBUTE_DIRECTORY) {
|
||||
strncpy(baseDstPath, data->target->path, FILE_PATH_MAX);
|
||||
} else {
|
||||
util_get_parent_path(baseDstPath, data->target->path, FILE_PATH_MAX);
|
||||
string_get_parent_path(baseDstPath, data->target->path, FILE_PATH_MAX);
|
||||
}
|
||||
|
||||
snprintf(dstPath, FILE_PATH_MAX, "%s%s", baseDstPath, ((file_info*) ((list_item*) linked_list_get(&data->contents, index))->data)->path + strlen(baseSrcPath));
|
||||
@ -75,20 +76,20 @@ static Result action_paste_contents_make_dst_directory(void* data, u32 index) {
|
||||
char dstPath[FILE_PATH_MAX];
|
||||
action_paste_contents_get_dst_path(pasteData, index, dstPath);
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(dstPath);
|
||||
FS_Path* fsPath = fs_make_path_utf8(dstPath);
|
||||
if(fsPath != NULL) {
|
||||
Handle dirHandle = 0;
|
||||
if(R_SUCCEEDED(FSUSER_OpenDirectory(&dirHandle, pasteData->target->archive, *fsPath))) {
|
||||
FSDIR_Close(dirHandle);
|
||||
} else if(R_SUCCEEDED(res = FSUSER_CreateDirectory(pasteData->target->archive, *fsPath, attributes))) {
|
||||
char parentPath[FILE_PATH_MAX];
|
||||
util_get_parent_path(parentPath, dstPath, FILE_PATH_MAX);
|
||||
string_get_parent_path(parentPath, dstPath, FILE_PATH_MAX);
|
||||
|
||||
char baseDstPath[FILE_PATH_MAX];
|
||||
if(pasteData->target->attributes & FS_ATTRIBUTE_DIRECTORY) {
|
||||
strncpy(baseDstPath, pasteData->target->path, FILE_PATH_MAX);
|
||||
} else {
|
||||
util_get_parent_path(baseDstPath, pasteData->target->path, FILE_PATH_MAX);
|
||||
string_get_parent_path(baseDstPath, pasteData->target->path, FILE_PATH_MAX);
|
||||
}
|
||||
|
||||
if(strncmp(parentPath, baseDstPath, FILE_PATH_MAX) == 0) {
|
||||
@ -99,7 +100,7 @@ static Result action_paste_contents_make_dst_directory(void* data, u32 index) {
|
||||
}
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -112,11 +113,11 @@ static Result action_paste_contents_open_src(void* data, u32 index, u32* handle)
|
||||
|
||||
Result res = 0;
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(((file_info*) ((list_item*) linked_list_get(&pasteData->contents, index))->data)->path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(((file_info*) ((list_item*) linked_list_get(&pasteData->contents, index))->data)->path);
|
||||
if(fsPath != NULL) {
|
||||
res = FSUSER_OpenFile(handle, clipboard_get_archive(), *fsPath, FS_OPEN_READ, 0);
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -144,7 +145,7 @@ static Result action_paste_contents_open_dst(void* data, u32 index, void* initia
|
||||
char dstPath[FILE_PATH_MAX];
|
||||
action_paste_contents_get_dst_path(pasteData, index, dstPath);
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(dstPath);
|
||||
FS_Path* fsPath = fs_make_path_utf8(dstPath);
|
||||
if(fsPath != NULL) {
|
||||
Handle currHandle;
|
||||
if(R_SUCCEEDED(FSUSER_OpenFile(&currHandle, pasteData->target->archive, *fsPath, FS_OPEN_READ, 0))) {
|
||||
@ -169,7 +170,7 @@ static Result action_paste_contents_open_dst(void* data, u32 index, void* initia
|
||||
res = FSUSER_OpenFile(handle, pasteData->target->archive, *fsPath, FS_OPEN_WRITE, 0);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -187,13 +188,13 @@ static Result action_paste_contents_close_dst(void* data, u32 index, bool succee
|
||||
action_paste_contents_get_dst_path(pasteData, index, dstPath);
|
||||
|
||||
char parentPath[FILE_PATH_MAX];
|
||||
util_get_parent_path(parentPath, dstPath, FILE_PATH_MAX);
|
||||
string_get_parent_path(parentPath, dstPath, FILE_PATH_MAX);
|
||||
|
||||
char baseDstPath[FILE_PATH_MAX];
|
||||
if(pasteData->target->attributes & FS_ATTRIBUTE_DIRECTORY) {
|
||||
strncpy(baseDstPath, pasteData->target->path, FILE_PATH_MAX);
|
||||
} else {
|
||||
util_get_parent_path(baseDstPath, pasteData->target->path, FILE_PATH_MAX);
|
||||
string_get_parent_path(baseDstPath, pasteData->target->path, FILE_PATH_MAX);
|
||||
}
|
||||
|
||||
if(strncmp(parentPath, baseDstPath, FILE_PATH_MAX) == 0) {
|
||||
@ -406,7 +407,7 @@ void action_paste_contents(linked_list* items, list_item* selected) {
|
||||
loadingData->popData.archive = clipboard_get_archive();
|
||||
strncpy(loadingData->popData.path, clipboard_get_path(), FILE_PATH_MAX);
|
||||
loadingData->popData.recursive = true;
|
||||
loadingData->popData.includeBase = !clipboard_is_contents_only() || !util_is_dir(clipboard_get_archive(), clipboard_get_path());
|
||||
loadingData->popData.includeBase = !clipboard_is_contents_only() || !fs_is_dir(clipboard_get_archive(), clipboard_get_path());
|
||||
loadingData->popData.filter = NULL;
|
||||
loadingData->popData.filterData = NULL;
|
||||
|
||||
|
@ -14,9 +14,10 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
|
||||
typedef struct {
|
||||
linked_list* items;
|
||||
@ -33,10 +34,10 @@ static void action_rename_onresponse(ui_view* view, void* data, SwkbdButton butt
|
||||
file_info* targetInfo = (file_info*) selected->data;
|
||||
|
||||
char fileName[FILE_NAME_MAX] = {'\0'};
|
||||
util_escape_file_name(fileName, response, sizeof(fileName));
|
||||
string_escape_file_name(fileName, response, sizeof(fileName));
|
||||
|
||||
char parentPath[FILE_PATH_MAX] = {'\0'};
|
||||
util_get_parent_path(parentPath, targetInfo->path, FILE_PATH_MAX);
|
||||
string_get_parent_path(parentPath, targetInfo->path, FILE_PATH_MAX);
|
||||
|
||||
char dstPath[FILE_PATH_MAX] = {'\0'};
|
||||
if(targetInfo->attributes & FS_ATTRIBUTE_DIRECTORY) {
|
||||
@ -45,9 +46,9 @@ static void action_rename_onresponse(ui_view* view, void* data, SwkbdButton butt
|
||||
snprintf(dstPath, FILE_PATH_MAX, "%s%s", parentPath, fileName);
|
||||
}
|
||||
|
||||
FS_Path* srcFsPath = util_make_path_utf8(targetInfo->path);
|
||||
FS_Path* srcFsPath = fs_make_path_utf8(targetInfo->path);
|
||||
if(srcFsPath != NULL) {
|
||||
FS_Path* dstFsPath = util_make_path_utf8(dstPath);
|
||||
FS_Path* dstFsPath = fs_make_path_utf8(dstPath);
|
||||
if(dstFsPath != NULL) {
|
||||
if(targetInfo->attributes & FS_ATTRIBUTE_DIRECTORY) {
|
||||
res = FSUSER_RenameDirectory(targetInfo->archive, *srcFsPath, targetInfo->archive, *dstFsPath);
|
||||
@ -55,12 +56,12 @@ static void action_rename_onresponse(ui_view* view, void* data, SwkbdButton butt
|
||||
res = FSUSER_RenameFile(targetInfo->archive, *srcFsPath, targetInfo->archive, *dstFsPath);
|
||||
}
|
||||
|
||||
util_free_path_utf8(dstFsPath);
|
||||
fs_free_path_utf8(dstFsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
util_free_path_utf8(srcFsPath);
|
||||
fs_free_path_utf8(srcFsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "../resources.h"
|
||||
#include "../ui.h"
|
||||
#include "../../core/error.h"
|
||||
#include "../../core/fs.h"
|
||||
#include "../../core/screen.h"
|
||||
#include "../../core/util.h"
|
||||
|
||||
static Result dumpnand_is_src_directory(void* data, u32 index, bool* isDirectory) {
|
||||
*isDirectory = false;
|
||||
@ -46,18 +46,18 @@ static Result dumpnand_open_dst(void* data, u32 index, void* initialReadBlock, u
|
||||
|
||||
FS_Archive sdmcArchive = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")))) {
|
||||
if(R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, "/fbi/")) && R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, "/fbi/nand/"))) {
|
||||
if(R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, "/fbi/")) && R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, "/fbi/nand/"))) {
|
||||
time_t t = time(NULL);
|
||||
struct tm* timeInfo = localtime(&t);
|
||||
|
||||
char path[FILE_PATH_MAX];
|
||||
strftime(path, sizeof(path), "/fbi/nand/NAND_%m-%d-%y_%H-%M-%S.bin", timeInfo);
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(path);
|
||||
if(fsPath != NULL) {
|
||||
res = FSUSER_OpenFileDirectly(handle, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""), *fsPath, FS_OPEN_WRITE | FS_OPEN_CREATE, 0);
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "../ui.h"
|
||||
#include "../../core/linkedlist.h"
|
||||
#include "../../core/screen.h"
|
||||
#include "../../core/util.h"
|
||||
#include "../../core/stringutil.h"
|
||||
|
||||
static list_item browse_user_save_data = {"Browse User Save Data", COLOR_TEXT, action_browse_user_ext_save_data};
|
||||
static list_item browse_spotpass_save_data = {"Browse SpotPass Save Data", COLOR_TEXT, action_browse_boss_ext_save_data};
|
||||
@ -241,15 +241,15 @@ static int extsavedata_compare(void* data, const void* p1, const void* p2) {
|
||||
|
||||
return id1 > id2 ? 1 : id1 < id2 ? -1 : 0;
|
||||
} else if(listData->sortByName) {
|
||||
bool title1HasName = data1->hasMeta && !util_is_string_empty(data1->meta.shortDescription);
|
||||
bool title2HasName = data2->hasMeta && !util_is_string_empty(data2->meta.shortDescription);
|
||||
bool title1HasName = data1->hasMeta && !string_is_empty(data1->meta.shortDescription);
|
||||
bool title2HasName = data2->hasMeta && !string_is_empty(data2->meta.shortDescription);
|
||||
|
||||
if(title1HasName && !title2HasName) {
|
||||
return -1;
|
||||
} else if(!title1HasName && title2HasName) {
|
||||
return 1;
|
||||
} else {
|
||||
return strcasecmp(info1->name, info2->name);
|
||||
return strncasecmp(info1->name, info2->name, sizeof(info1->name));
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -13,9 +13,10 @@
|
||||
#include "../resources.h"
|
||||
#include "../ui.h"
|
||||
#include "../../core/clipboard.h"
|
||||
#include "../../core/fs.h"
|
||||
#include "../../core/linkedlist.h"
|
||||
#include "../../core/screen.h"
|
||||
#include "../../core/util.h"
|
||||
#include "../../core/stringutil.h"
|
||||
|
||||
static list_item rename_opt = {"Rename", COLOR_TEXT, action_rename};
|
||||
static list_item copy = {"Copy", COLOR_TEXT, NULL};
|
||||
@ -274,7 +275,7 @@ static void files_free_data(files_data* data) {
|
||||
}
|
||||
|
||||
if(data->archive != 0) {
|
||||
util_close_archive(data->archive);
|
||||
fs_close_archive(data->archive);
|
||||
data->archive = 0;
|
||||
}
|
||||
|
||||
@ -297,9 +298,9 @@ static void files_update(ui_view* view, void* data, linked_list* items, list_ite
|
||||
}
|
||||
}
|
||||
|
||||
while(!util_is_dir(listData->archive, listData->currDir)) {
|
||||
while(!fs_is_dir(listData->archive, listData->currDir)) {
|
||||
char parentDir[FILE_PATH_MAX] = {'\0'};
|
||||
util_get_parent_path(parentDir, listData->currDir, FILE_PATH_MAX);
|
||||
string_get_parent_path(parentDir, listData->currDir, FILE_PATH_MAX);
|
||||
|
||||
files_navigate(listData, items, parentDir);
|
||||
}
|
||||
@ -316,7 +317,7 @@ static void files_update(ui_view* view, void* data, linked_list* items, list_ite
|
||||
return;
|
||||
} else {
|
||||
char parentDir[FILE_PATH_MAX] = {'\0'};
|
||||
util_get_parent_path(parentDir, listData->currDir, FILE_PATH_MAX);
|
||||
string_get_parent_path(parentDir, listData->currDir, FILE_PATH_MAX);
|
||||
|
||||
files_navigate(listData, items, parentDir);
|
||||
}
|
||||
@ -359,7 +360,7 @@ static bool files_filter(void* data, const char* name, u32 attributes) {
|
||||
if((attributes & FS_ATTRIBUTE_DIRECTORY) != 0) {
|
||||
return listData->showDirectories;
|
||||
} else {
|
||||
if((util_filter_cias(NULL, name, attributes) && !listData->showCias) || (util_filter_tickets(NULL, name, attributes) && !listData->showTickets)) {
|
||||
if((fs_filter_cias(NULL, name, attributes) && !listData->showCias) || (fs_filter_tickets(NULL, name, attributes) && !listData->showTickets)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -411,7 +412,7 @@ void files_open(FS_ArchiveID archiveId, FS_Path archivePath) {
|
||||
snprintf(data->currDir, FILE_PATH_MAX, "/");
|
||||
|
||||
Result res = 0;
|
||||
if(R_FAILED(res = util_open_archive(&data->archive, archiveId, archivePath))) {
|
||||
if(R_FAILED(res = fs_open_archive(&data->archive, archiveId, archivePath))) {
|
||||
error_display_res(NULL, NULL, res, "Failed to open file listing archive.");
|
||||
|
||||
files_free_data(data);
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include "../resources.h"
|
||||
#include "../ui.h"
|
||||
#include "../../core/error.h"
|
||||
#include "../../core/fs.h"
|
||||
#include "../../core/linkedlist.h"
|
||||
#include "../../core/screen.h"
|
||||
#include "../../core/util.h"
|
||||
#include "../../core/task/capturecam.h"
|
||||
#include "../../libs/quirc/quirc_internal.h"
|
||||
|
||||
@ -60,7 +60,7 @@ static Result remoteinstall_set_last_urls(const char* urls) {
|
||||
|
||||
if(urls != NULL && strlen(urls) != 0
|
||||
&& R_SUCCEEDED(res)
|
||||
&& R_SUCCEEDED(res = util_ensure_dir(sdmcArchive, "/fbi/"))
|
||||
&& R_SUCCEEDED(res = fs_ensure_dir(sdmcArchive, "/fbi/"))
|
||||
&& R_SUCCEEDED(res = FSUSER_OpenFile(&file, sdmcArchive, path, FS_OPEN_WRITE | FS_OPEN_CREATE, 0))) {
|
||||
u32 bytesWritten = 0;
|
||||
res = FSFILE_Write(file, &bytesWritten, 0, urls, strlen(urls), FS_WRITE_FLUSH | FS_WRITE_UPDATE_TIME);
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include "../../resources.h"
|
||||
#include "../../ui.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/http.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/task/task.h"
|
||||
|
||||
static Result task_data_op_check_running(data_op_data* data, u32 index, u32* srcHandle, u32* dstHandle) {
|
||||
@ -297,7 +297,7 @@ Result task_download_seed_sync(u64 titleId) {
|
||||
|
||||
Result res = 0;
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(pathBuf);
|
||||
FS_Path* fsPath = fs_make_path_utf8(pathBuf);
|
||||
if(fsPath != NULL) {
|
||||
u8 seed[16];
|
||||
|
||||
@ -309,7 +309,7 @@ Result task_download_seed_sync(u64 titleId) {
|
||||
FSFILE_Close(fileHandle);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
|
||||
if(R_FAILED(res)) {
|
||||
u8 region = CFG_REGION_USA;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
#include "../../../core/data/smdh.h"
|
||||
#include "../../../core/task/task.h"
|
||||
|
||||
@ -72,7 +72,7 @@ static Result task_populate_ext_save_data_from(populate_ext_save_data_data* data
|
||||
free(smdh);
|
||||
}
|
||||
|
||||
if(util_is_string_empty(item->name)) {
|
||||
if(string_is_empty(item->name)) {
|
||||
snprintf(item->name, LIST_ITEM_NAME_MAX, "%016llX", extSaveDataIds[i]);
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,10 @@
|
||||
#include "../../list.h"
|
||||
#include "../../resources.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
#include "../../../core/data/cia.h"
|
||||
#include "../../../core/data/smdh.h"
|
||||
#include "../../../core/task/task.h"
|
||||
@ -51,14 +52,14 @@ Result task_create_file_item(list_item** out, FS_Archive archive, const char* pa
|
||||
file_info* fileInfo = (file_info*) calloc(1, sizeof(file_info));
|
||||
if(fileInfo != NULL) {
|
||||
fileInfo->archive = archive;
|
||||
util_get_path_file(fileInfo->name, path, FILE_NAME_MAX);
|
||||
string_get_path_file(fileInfo->name, path, FILE_NAME_MAX);
|
||||
fileInfo->attributes = attributes != UINT32_MAX ? attributes : 0;
|
||||
|
||||
fileInfo->size = 0;
|
||||
fileInfo->isCia = false;
|
||||
fileInfo->isTicket = false;
|
||||
|
||||
if((attributes != UINT32_MAX && (attributes & FS_ATTRIBUTE_DIRECTORY)) || util_is_dir(archive, path)) {
|
||||
if((attributes != UINT32_MAX && (attributes & FS_ATTRIBUTE_DIRECTORY)) || fs_is_dir(archive, path)) {
|
||||
item->color = COLOR_DIRECTORY;
|
||||
|
||||
size_t len = strlen(path);
|
||||
@ -76,7 +77,7 @@ Result task_create_file_item(list_item** out, FS_Archive archive, const char* pa
|
||||
|
||||
strncpy(fileInfo->path, path, FILE_PATH_MAX);
|
||||
|
||||
FS_Path* fileFsPath = util_make_path_utf8(fileInfo->path);
|
||||
FS_Path* fileFsPath = fs_make_path_utf8(fileInfo->path);
|
||||
if(fileFsPath != NULL) {
|
||||
Handle fileHandle;
|
||||
if(R_SUCCEEDED(FSUSER_OpenFile(&fileHandle, archive, *fileFsPath, FS_OPEN_READ, 0))) {
|
||||
@ -86,7 +87,7 @@ Result task_create_file_item(list_item** out, FS_Archive archive, const char* pa
|
||||
|
||||
FSFILE_GetSize(fileHandle, &fileInfo->size);
|
||||
|
||||
if(util_filter_cias(NULL, fileInfo->path, fileInfo->attributes)) {
|
||||
if(fs_filter_cias(NULL, fileInfo->path, fileInfo->attributes)) {
|
||||
AM_TitleEntry titleEntry;
|
||||
if(R_SUCCEEDED(AM_GetCiaFileInfo(MEDIATYPE_SD, &titleEntry, fileHandle))) {
|
||||
fileInfo->isCia = true;
|
||||
@ -95,7 +96,7 @@ Result task_create_file_item(list_item** out, FS_Archive archive, const char* pa
|
||||
fileInfo->ciaInfo.installedSize = titleEntry.size;
|
||||
fileInfo->ciaInfo.hasMeta = false;
|
||||
|
||||
if(util_get_title_destination(titleEntry.titleID) != MEDIATYPE_SD && R_SUCCEEDED(AM_GetCiaFileInfo(MEDIATYPE_NAND, &titleEntry, fileHandle))) {
|
||||
if(fs_get_title_destination(titleEntry.titleID) != MEDIATYPE_SD && R_SUCCEEDED(AM_GetCiaFileInfo(MEDIATYPE_NAND, &titleEntry, fileHandle))) {
|
||||
fileInfo->ciaInfo.installedSize = titleEntry.size;
|
||||
}
|
||||
|
||||
@ -118,7 +119,7 @@ Result task_create_file_item(list_item** out, FS_Archive archive, const char* pa
|
||||
free(smdh);
|
||||
}
|
||||
}
|
||||
} else if(util_filter_tickets(NULL, fileInfo->path, fileInfo->attributes)) {
|
||||
} else if(fs_filter_tickets(NULL, fileInfo->path, fileInfo->attributes)) {
|
||||
u32 bytesRead = 0;
|
||||
|
||||
u8 sigType = 0;
|
||||
@ -138,7 +139,7 @@ Result task_create_file_item(list_item** out, FS_Archive archive, const char* pa
|
||||
FSFILE_Close(fileHandle);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fileFsPath);
|
||||
fs_free_path_utf8(fileFsPath);
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +174,7 @@ static int task_populate_files_compare_directory_entries(const void* e1, const v
|
||||
char entryName2[0x213] = {'\0'};
|
||||
utf16_to_utf8((uint8_t*) entryName2, ent2->name, sizeof(entryName2) - 1);
|
||||
|
||||
return strcasecmp(entryName1, entryName2);
|
||||
return strncasecmp(entryName1, entryName2, sizeof(entryName1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,7 +209,7 @@ static void task_populate_files_thread(void* arg) {
|
||||
}
|
||||
|
||||
if(curr->attributes & FS_ATTRIBUTE_DIRECTORY) {
|
||||
FS_Path* fsPath = util_make_path_utf8(curr->path);
|
||||
FS_Path* fsPath = fs_make_path_utf8(curr->path);
|
||||
if(fsPath != NULL) {
|
||||
Handle dirHandle = 0;
|
||||
if(R_SUCCEEDED(res = FSUSER_OpenDirectory(&dirHandle, curr->archive, *fsPath))) {
|
||||
@ -252,7 +253,7 @@ static void task_populate_files_thread(void* arg) {
|
||||
FSDIR_Close(dirHandle);
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
} else {
|
||||
res = R_APP_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/task/task.h"
|
||||
|
||||
static int task_populate_pending_titles_compare_ids(const void* e1, const void* e2) {
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/task/task.h"
|
||||
|
||||
#define MAX_SYSTEM_SAVE_DATA 512
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/task/task.h"
|
||||
|
||||
static int task_populate_tickets_compare_ids(const void* e1, const void* e2) {
|
||||
|
@ -10,9 +10,10 @@
|
||||
#include "../../list.h"
|
||||
#include "../../resources.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
#include "../../../core/task/task.h"
|
||||
#include "../../../libs/stb_image/stb_image.h"
|
||||
|
||||
@ -24,7 +25,7 @@ void task_populate_titledb_update_status(list_item* item) {
|
||||
|
||||
if(info->cia.exists) {
|
||||
AM_TitleEntry entry;
|
||||
info->cia.installed = R_SUCCEEDED(AM_GetTitleInfo(util_get_title_destination(info->cia.titleId), 1, &info->cia.titleId, &entry));
|
||||
info->cia.installed = R_SUCCEEDED(AM_GetTitleInfo(fs_get_title_destination(info->cia.titleId), 1, &info->cia.titleId, &entry));
|
||||
info->cia.installedVersion = info->cia.installed ? entry.version : (u16) 0;
|
||||
}
|
||||
|
||||
@ -32,12 +33,12 @@ void task_populate_titledb_update_status(list_item* item) {
|
||||
info->tdsx.installed = false;
|
||||
|
||||
char name[FILE_NAME_MAX];
|
||||
util_escape_file_name(name, info->meta.shortDescription, sizeof(name));
|
||||
string_escape_file_name(name, info->meta.shortDescription, sizeof(name));
|
||||
|
||||
char path3dsx[FILE_PATH_MAX];
|
||||
snprintf(path3dsx, sizeof(path3dsx), "/3ds/%s/%s.3dsx", name, name);
|
||||
|
||||
FS_Path* fsPath = util_make_path_utf8(path3dsx);
|
||||
FS_Path* fsPath = fs_make_path_utf8(path3dsx);
|
||||
if(fsPath != NULL) {
|
||||
Handle handle = 0;
|
||||
if(R_SUCCEEDED(FSUSER_OpenFileDirectly(&handle, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""), *fsPath, FS_OPEN_READ, 0))) {
|
||||
@ -46,7 +47,7 @@ void task_populate_titledb_update_status(list_item* item) {
|
||||
info->tdsx.installed = true;
|
||||
}
|
||||
|
||||
util_free_path_utf8(fsPath);
|
||||
fs_free_path_utf8(fsPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,10 @@
|
||||
#include "../../list.h"
|
||||
#include "../../resources.h"
|
||||
#include "../../../core/error.h"
|
||||
#include "../../../core/fs.h"
|
||||
#include "../../../core/linkedlist.h"
|
||||
#include "../../../core/screen.h"
|
||||
#include "../../../core/util.h"
|
||||
#include "../../../core/stringutil.h"
|
||||
#include "../../../core/data/bnr.h"
|
||||
#include "../../../core/data/smdh.h"
|
||||
#include "../../../core/task/task.h"
|
||||
@ -37,7 +38,9 @@ static Result task_populate_titles_add_ctr(populate_titles_data* data, FS_MediaT
|
||||
u32 archivePath[4] = {(u32) (titleId & 0xFFFFFFFF), (u32) ((titleId >> 32) & 0xFFFFFFFF), mediaType, 0x00000000};
|
||||
|
||||
Handle fileHandle;
|
||||
if(R_SUCCEEDED(FSUSER_OpenFileDirectly(&fileHandle, ARCHIVE_SAVEDATA_AND_CONTENT, util_make_binary_path(archivePath, sizeof(archivePath)), util_make_binary_path(filePath, sizeof(filePath)), FS_OPEN_READ, 0))) {
|
||||
if(R_SUCCEEDED(FSUSER_OpenFileDirectly(&fileHandle, ARCHIVE_SAVEDATA_AND_CONTENT,
|
||||
fs_make_path_binary(archivePath, sizeof(archivePath)),
|
||||
fs_make_path_binary(filePath, sizeof(filePath)), FS_OPEN_READ, 0))) {
|
||||
SMDH* smdh = (SMDH*) calloc(1, sizeof(SMDH));
|
||||
if(smdh != NULL) {
|
||||
u32 bytesRead = 0;
|
||||
@ -64,7 +67,7 @@ static Result task_populate_titles_add_ctr(populate_titles_data* data, FS_MediaT
|
||||
FSFILE_Close(fileHandle);
|
||||
}
|
||||
|
||||
if(util_is_string_empty(item->name)) {
|
||||
if(string_is_empty(item->name)) {
|
||||
snprintf(item->name, LIST_ITEM_NAME_MAX, "%016llX", titleId);
|
||||
}
|
||||
|
||||
@ -200,7 +203,7 @@ static Result task_populate_titles_add_twl(populate_titles_data* data, FS_MediaT
|
||||
free(bnr);
|
||||
}
|
||||
|
||||
if(util_is_string_empty(item->name)) {
|
||||
if(string_is_empty(item->name)) {
|
||||
snprintf(item->name, LIST_ITEM_NAME_MAX, "%016llX", realTitleId);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "../ui.h"
|
||||
#include "../../core/linkedlist.h"
|
||||
#include "../../core/screen.h"
|
||||
#include "../../core/util.h"
|
||||
#include "../../core/stringutil.h"
|
||||
|
||||
static list_item launch_title = {"Launch Title", COLOR_TEXT, action_launch_title};
|
||||
static list_item delete_title = {"Delete Title", COLOR_TEXT, action_delete_title};
|
||||
@ -292,15 +292,15 @@ static int titles_compare(void* data, const void* p1, const void* p2) {
|
||||
|
||||
return id1 > id2 ? 1 : id1 < id2 ? -1 : 0;
|
||||
} else if(listData->sortByName) {
|
||||
bool title1HasName = title1->hasMeta && !util_is_string_empty(title1->meta.shortDescription);
|
||||
bool title2HasName = title2->hasMeta && !util_is_string_empty(title2->meta.shortDescription);
|
||||
bool title1HasName = title1->hasMeta && !string_is_empty(title1->meta.shortDescription);
|
||||
bool title2HasName = title2->hasMeta && !string_is_empty(title2->meta.shortDescription);
|
||||
|
||||
if(title1HasName && !title2HasName) {
|
||||
return -1;
|
||||
} else if(!title1HasName && title2HasName) {
|
||||
return 1;
|
||||
} else {
|
||||
return strcasecmp(info1->name, info2->name);
|
||||
return strncasecmp(info1->name, info2->name, sizeof(info1->name));
|
||||
}
|
||||
} else if(listData->sortBySize) {
|
||||
u64 size1 = title1->installedSize;
|
||||
|
@ -14,8 +14,8 @@
|
||||
#include "../resources.h"
|
||||
#include "../ui.h"
|
||||
#include "../../core/error.h"
|
||||
#include "../../core/fs.h"
|
||||
#include "../../core/screen.h"
|
||||
#include "../../core/util.h"
|
||||
|
||||
static void update_check_update(ui_view* view, void* data, float* progress, char* text) {
|
||||
bool hasUpdate = false;
|
||||
@ -43,7 +43,7 @@ static void update_check_update(ui_view* view, void* data, float* progress, char
|
||||
json_t* assetUrl = json_object_get(val, "browser_download_url");
|
||||
|
||||
if(json_is_string(assetName) && json_is_string(assetUrl)) {
|
||||
if(strncmp(json_string_value(assetName), util_get_3dsx_path() != NULL ? "FBI.3dsx" : "FBI.cia", json_string_length(assetName)) == 0) {
|
||||
if(strncmp(json_string_value(assetName), fs_get_3dsx_path() != NULL ? "FBI.3dsx" : "FBI.cia", json_string_length(assetName)) == 0) {
|
||||
url = json_string_value(assetUrl);
|
||||
break;
|
||||
}
|
||||
@ -72,7 +72,7 @@ static void update_check_update(ui_view* view, void* data, float* progress, char
|
||||
info_destroy(view);
|
||||
|
||||
if(hasUpdate) {
|
||||
action_install_url("Update FBI to the latest version?", updateURL, util_get_3dsx_path(), NULL, NULL, NULL);
|
||||
action_install_url("Update FBI to the latest version?", updateURL, fs_get_3dsx_path(), NULL, NULL, NULL);
|
||||
} else {
|
||||
if(R_FAILED(res)) {
|
||||
error_display_res(NULL, NULL, res, "Failed to check for update.");
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "section/task/uitask.h"
|
||||
#include "../core/error.h"
|
||||
#include "../core/screen.h"
|
||||
#include "../core/util.h"
|
||||
#include "../core/data/smdh.h"
|
||||
|
||||
#define MAX_UI_VIEWS 16
|
||||
|
Loading…
x
Reference in New Issue
Block a user