Adapt to libnx 3.0.0-1 (#73)

This commit is contained in:
octopuserectus 2020-01-04 20:29:18 +01:00 committed by Joel
parent 1f1e378137
commit af3ea54eaa
11 changed files with 42 additions and 42 deletions

View File

@ -48,7 +48,7 @@ Result Config_Load(void) {
}
u64 size = 0;
FS_GetFileSize(fs, "/switch/NX-Shell/config.cfg", &size);
FS_Getfile_size(fs, "/switch/NX-Shell/config.cfg", &size);
char *buf = (char *)malloc(size + 1);
if (R_FAILED(ret = FS_ReadFile(fs, "/switch/NX-Shell/config.cfg", size, buf))) {
@ -85,7 +85,7 @@ Result Config_GetLastDirectory(void) {
}
else {
u64 size = 0;
FS_GetFileSize(fs, "/switch/NX-Shell/lastdir.txt", &size);
FS_Getfile_size(fs, "/switch/NX-Shell/lastdir.txt", &size);
char *buf = (char *)malloc(size + 1);
if (R_FAILED(ret = FS_ReadFile(fs, "/switch/NX-Shell/lastdir.txt", size, buf))) {

View File

@ -27,9 +27,9 @@ static int cmpstringp(const void *p1, const void *p2) {
FsDirectoryEntry *entryB = (FsDirectoryEntry *)p2;
u64 sizeA = 0, sizeB = 0;
if ((entryA->type == ENTRYTYPE_DIR) && !(entryB->type == ENTRYTYPE_DIR))
if ((entryA->type == FsDirEntryType_Dir) && !(entryB->type == FsDirEntryType_Dir))
return -1;
else if (!(entryA->type == ENTRYTYPE_DIR) && (entryB->type == ENTRYTYPE_DIR))
else if (!(entryA->type == FsDirEntryType_Dir) && (entryB->type == FsDirEntryType_Dir))
return 1;
else {
switch(config.sort) {
@ -42,14 +42,14 @@ static int cmpstringp(const void *p1, const void *p2) {
break;
case 2: // Sort by file size (largest first)
sizeA = entryA->fileSize;
sizeB = entryB->fileSize;
sizeA = entryA->file_size;
sizeB = entryB->file_size;
return sizeA > sizeB? -1 : sizeA < sizeB? 1 : 0;
break;
case 3: // Sort by file size (smallest first)
sizeA = entryA->fileSize;
sizeB = entryB->fileSize;
sizeA = entryA->file_size;
sizeB = entryB->file_size;
return sizeB > sizeA? -1 : sizeB < sizeA? 1 : 0;
break;
}
@ -66,7 +66,7 @@ Result Dirbrowse_PopulateFiles(bool clear) {
FsDir dir;
Result ret = 0;
if (R_SUCCEEDED(ret = FS_OpenDirectory(fs, cwd, FS_DIROPEN_DIRECTORY | FS_DIROPEN_FILE, &dir))) {
if (R_SUCCEEDED(ret = FS_OpenDirectory(fs, cwd, FsDirOpenMode_ReadDirs | FsDirOpenMode_ReadFiles, &dir))) {
/* Add fake ".." entry except on root */
if (strcmp(cwd, ROOT_PATH)) {
files = (File *)malloc(sizeof(File)); // New list
@ -100,8 +100,8 @@ Result Dirbrowse_PopulateFiles(bool clear) {
strcpy(item->name, entries[i].name);
strcpy(item->ext, FS_GetFileExt(item->name));
item->size = entries[i].fileSize;
item->isDir = entries[i].type == ENTRYTYPE_DIR;
item->size = entries[i].file_size;
item->isDir = entries[i].type == FsDirEntryType_Dir;
if (files == NULL) // New list
files = item;

View File

@ -14,7 +14,7 @@ bool FS_FileExists(FsFileSystem *fs, const char *path) {
char temp_path[FS_MAX_PATH];
snprintf(temp_path, FS_MAX_PATH, path);
if (R_SUCCEEDED(fsFsOpenFile(fs, temp_path, FS_OPEN_READ, &file))) {
if (R_SUCCEEDED(fsFsOpenFile(fs, temp_path, FsOpenMode_Read, &file))) {
fsFileClose(&file);
return true;
}
@ -28,7 +28,7 @@ bool FS_DirExists(FsFileSystem *fs, const char *path) {
char temp_path[FS_MAX_PATH];
snprintf(temp_path, FS_MAX_PATH, path);
if (R_SUCCEEDED(fsFsOpenDirectory(fs, temp_path, FS_DIROPEN_DIRECTORY, &dir))) {
if (R_SUCCEEDED(fsFsOpenDirectory(fs, temp_path, FsDirOpenMode_ReadDirs, &dir))) {
fsDirClose(&dir);
return true;
}
@ -100,7 +100,7 @@ Result FS_GetDirEntryCount(FsDir *dir, u64 *count) {
Result FS_ReadDir(FsDir *dir, u64 inval, size_t *total_entries, size_t max_entries, FsDirectoryEntry *entry) {
Result ret = 0;
if (R_FAILED(ret = fsDirRead(dir, inval, total_entries, max_entries, entry))) {
if (R_FAILED(ret = fsDirRead(dir, total_entries, max_entries, entry))) {
if (config.dev_options)
DEBUG_LOG("fsDirRead(%s, %d) failed: 0x%lx\n", cwd, max_entries, ret);
@ -110,18 +110,18 @@ Result FS_ReadDir(FsDir *dir, u64 inval, size_t *total_entries, size_t max_entri
return 0;
}
Result FS_GetFileSize(FsFileSystem *fs, const char *path, u64 *size) {
Result FS_Getfile_size(FsFileSystem *fs, const char *path, u64 *size) {
Result ret = 0;
FsFile file;
char temp_path[FS_MAX_PATH];
snprintf(temp_path, FS_MAX_PATH, path);
if (R_FAILED(ret = fsFsOpenFile(fs, temp_path, FS_OPEN_READ, &file))) {
if (R_FAILED(ret = fsFsOpenFile(fs, temp_path, FsOpenMode_Read, &file))) {
fsFileClose(&file);
if (config.dev_options)
DEBUG_LOG("fsFsOpenFile(%s, FS_OPEN_READ, %llu) failed: 0x%lx\n", temp_path, &size, ret);
DEBUG_LOG("fsFsOpenFile(%s, FsOpenMode_Read, %llu) failed: 0x%lx\n", temp_path, &size, ret);
return ret;
}
@ -229,16 +229,16 @@ Result FS_ReadFile(FsFileSystem *fs, const char *path, size_t size, void *buf) {
char temp_path[FS_MAX_PATH];
snprintf(temp_path, FS_MAX_PATH, path);
if (R_FAILED(ret = fsFsOpenFile(fs, temp_path, FS_OPEN_READ, &file))) {
if (R_FAILED(ret = fsFsOpenFile(fs, temp_path, FsOpenMode_Read, &file))) {
fsFileClose(&file);
if (config.dev_options)
DEBUG_LOG("fsFsOpenFile(%s, FS_OPEN_READ, %llu) failed: 0x%lx\n", temp_path, &size, ret);
DEBUG_LOG("fsFsOpenFile(%s, FsOpenMode_Read, %llu) failed: 0x%lx\n", temp_path, &size, ret);
return ret;
}
if (R_FAILED(ret = fsFileRead(&file, 0, buf, size, FS_READOPTION_NONE, &out))) {
if (R_FAILED(ret = fsFileRead(&file, 0, buf, size, FsReadOption_None, &out))) {
fsFileClose(&file);
if (config.dev_options)
@ -278,16 +278,16 @@ Result FS_WriteFile(FsFileSystem *fs, const char *path, const void *buf, bool fl
return ret;
}
if (R_FAILED(ret = fsFsOpenFile(fs, temp_path, FS_OPEN_WRITE, &file))) {
if (R_FAILED(ret = fsFsOpenFile(fs, temp_path, FsOpenMode_Write, &file))) {
fsFileClose(&file);
if (config.dev_options)
DEBUG_LOG("fsFsOpenFile(%s, FS_OPEN_WRITE) failed: 0x%lx\n", temp_path, ret);
DEBUG_LOG("fsFsOpenFile(%s, FsOpenMode_Write) failed: 0x%lx\n", temp_path, ret);
return ret;
}
if (R_FAILED(ret = fsFileWrite(&file, 0, buf, size + len, flush? FS_WRITEOPTION_FLUSH : FS_WRITEOPTION_NONE))) {
if (R_FAILED(ret = fsFileWrite(&file, 0, buf, size + len, flush? FsWriteOption_Flush : FsWriteOption_None))) {
fsFileClose(&file);
if (config.dev_options)
@ -316,9 +316,9 @@ Result FS_SetArchiveBit(FsFileSystem *fs, const char *path) {
char temp_path[FS_MAX_PATH];
snprintf(temp_path, FS_MAX_PATH, path);
if (R_FAILED(ret = fsFsSetArchiveBit(fs, temp_path))) {
if (R_FAILED(ret = FS_SetArchiveBit(fs, temp_path))) {
if (config.dev_options)
DEBUG_LOG("fsFsSetArchiveBit(%s) failed: 0x%lx\n", temp_path, ret);
DEBUG_LOG("FS_SetArchiveBit(%s) failed: 0x%lx\n", temp_path, ret);
return ret;
}

View File

@ -135,7 +135,7 @@ struct ftp_session_t {
size_t buffersize; /*! persistent buffer size between callbacks */
size_t cmd_buffersize;
uint64_t filepos; /*! persistent file position between callbacks */
uint64_t filesize; /*! persistent file size between callbacks */
uint64_t file_size; /*! persistent file size between callbacks */
FILE *fp; /*! persistent open file pointer between callbacks */
DIR *dp; /*! persistent open directory pointer between callbacks */
};
@ -444,7 +444,7 @@ static int ftp_session_open_file_read(ftp_session_t *session) {
//console_print(RED "fstat '%s': %d %s\n" RESET, session->buffer, errno, strerror(errno));
return -1;
}
session->filesize = st.st_size;
session->file_size = st.st_size;
if(session->filepos != 0)
{

View File

@ -15,7 +15,7 @@
static void *addr;
static void Term_Services(void) {
if (fsdevGetDeviceFileSystem("DEV_USER"))
if (("DEV_USER"))
fsdevUnmountDevice("DEV_USER");
if (fsdevGetDeviceFileSystem("DEV_SYSTEM"))
@ -57,7 +57,7 @@ static Result Init_Services(void) {
Textures_Load();
BROWSE_STATE = STATE_SD;
devices[0] = *fsdevGetDefaultFileSystem();
devices[0] = *fsdevGetDeviceFileSystem("sdmc");
fs = &devices[0];
total_storage = Utils_GetTotalStorage(fs);

View File

@ -287,7 +287,7 @@ void Menu_DisplayProperties(void) {
char utils_size[16];
u64 size = 0;
FS_GetFileSize(fs, path, &size);
FS_Getfile_size(fs, path, &size);
Utils_GetSizeString(utils_size, size);
SDL_DrawTextf(390, 183, 25, config.dark_theme? TEXT_MIN_COLOUR_DARK : TEXT_MIN_COLOUR_LIGHT, "Name: %s", file->name);
@ -313,7 +313,7 @@ static int FileOptions_CopyFile(char *src, char *dst, bool display_animation) {
snprintf(temp_path_src, FS_MAX_PATH, src);
snprintf(temp_path_dst, FS_MAX_PATH, dst);
if (R_FAILED(ret = fsFsOpenFile(&devices[PREVIOUS_BROWSE_STATE], temp_path_src, FS_OPEN_READ, &src_handle))) {
if (R_FAILED(ret = fsFsOpenFile(&devices[PREVIOUS_BROWSE_STATE], temp_path_src, FsOpenMode_Read, &src_handle))) {
fsFileClose(&src_handle);
Menu_DisplayError("fsFsOpenFile(src_handle) failed:", ret);
return ret;
@ -328,7 +328,7 @@ static int FileOptions_CopyFile(char *src, char *dst, bool display_animation) {
if (!FS_FileExists(fs, temp_path_dst))
fsFsCreateFile(fs, temp_path_dst, size, 0);
if (R_FAILED(ret = fsFsOpenFile(fs, temp_path_dst, FS_OPEN_WRITE, &dst_handle))) {
if (R_FAILED(ret = fsFsOpenFile(fs, temp_path_dst, FsOpenMode_Write, &dst_handle))) {
fsFileClose(&src_handle);
fsFileClose(&dst_handle);
Menu_DisplayError("fsFsOpenFile(dst_handle) failed:", ret);
@ -343,14 +343,14 @@ static int FileOptions_CopyFile(char *src, char *dst, bool display_animation) {
do {
memset(buf, 0, buf_size);
if (R_FAILED(ret = fsFileRead(&src_handle, offset, buf, buf_size, FS_READOPTION_NONE, &bytes_read))) {
if (R_FAILED(ret = fsFileRead(&src_handle, offset, buf, buf_size, FsReadOption_None, &bytes_read))) {
free(buf);
fsFileClose(&src_handle);
fsFileClose(&dst_handle);
Menu_DisplayError("fsFileRead() failed:", ret);
return ret;
}
if (R_FAILED(ret = fsFileWrite(&dst_handle, offset, buf, bytes_read, FS_WRITEOPTION_FLUSH))) {
if (R_FAILED(ret = fsFileWrite(&dst_handle, offset, buf, bytes_read, FsWriteOption_Flush))) {
free(buf);
fsFileClose(&src_handle);
fsFileClose(&dst_handle);
@ -374,7 +374,7 @@ static Result FileOptions_CopyDir(char *src, char *dst) {
FsDir dir;
Result ret = 0;
if (R_SUCCEEDED(ret = FS_OpenDirectory(&devices[PREVIOUS_BROWSE_STATE], src, FS_DIROPEN_DIRECTORY | FS_DIROPEN_FILE, &dir))) {
if (R_SUCCEEDED(ret = FS_OpenDirectory(&devices[PREVIOUS_BROWSE_STATE], src, FsDirOpenMode_ReadDirs | FsDirOpenMode_ReadFiles, &dir))) {
FS_MakeDir(fs, dst);
u64 entryCount = 0;
@ -411,7 +411,7 @@ static Result FileOptions_CopyDir(char *src, char *dst) {
strcpy(outbuffer + strlen(outbuffer), entries[i].name);
// Another Folder
if (entries[i].type == ENTRYTYPE_DIR)
if (entries[i].type == FsDirEntryType_Dir)
FileOptions_CopyDir(inbuffer, outbuffer); // Copy Folder (via recursion)
// Simple File

View File

@ -12,7 +12,7 @@
#include "touch_helper.h"
void Menu_FTP(void) {
nifmInitialize();
nifmInitialize(1);
ftp_init();
char hostname[128];

View File

@ -17,7 +17,7 @@ static Result Gallery_GetImageList(void) {
FsDir dir;
Result ret = 0;
if (R_SUCCEEDED(ret = FS_OpenDirectory(fs, cwd, FS_DIROPEN_DIRECTORY | FS_DIROPEN_FILE, &dir))) {
if (R_SUCCEEDED(ret = FS_OpenDirectory(fs, cwd, FsDirOpenMode_ReadDirs | FsDirOpenMode_ReadFiles, &dir))) {
u64 entryCount = 0;
if (R_FAILED(ret = FS_GetDirEntryCount(&dir, &entryCount)))

View File

@ -42,7 +42,7 @@ void Mount_Device(int device) {
fsdevMountDevice(devices_list[device], devices[device]);
}
fs = device == 0? fsdevGetDefaultFileSystem() : &devices[device];
fs = device == 0? fsdevGetDeviceFileSystem("sdmc") : &devices[device];
BROWSE_STATE = device;
total_storage = Utils_GetTotalStorage(fs);

View File

@ -27,7 +27,7 @@ static Result Menu_GetMusicList(void) {
FsDir dir;
Result ret = 0;
if (R_SUCCEEDED(ret = FS_OpenDirectory(fs, cwd, FS_DIROPEN_DIRECTORY | FS_DIROPEN_FILE, &dir))) {
if (R_SUCCEEDED(ret = FS_OpenDirectory(fs, cwd, FsDirOpenMode_ReadDirs | FsDirOpenMode_ReadFiles, &dir))) {
u64 entryCount = 0;
if (R_FAILED(ret = FS_GetDirEntryCount(&dir, &entryCount)))

View File

@ -37,9 +37,9 @@ int Utils_Alphasort(const void *p1, const void *p2) {
FsDirectoryEntry *entryA = (FsDirectoryEntry *)p1;
FsDirectoryEntry *entryB = (FsDirectoryEntry *)p2;
if ((entryA->type == ENTRYTYPE_DIR) && !(entryB->type == ENTRYTYPE_DIR))
if ((entryA->type == FsDirEntryType_Dir) && !(entryB->type == FsDirEntryType_Dir))
return -1;
else if (!(entryA->type == ENTRYTYPE_DIR) && (entryB->type == ENTRYTYPE_DIR))
else if (!(entryA->type == FsDirEntryType_Dir) && (entryB->type == FsDirEntryType_Dir))
return 1;
return strcasecmp(entryA->name, entryB->name);