1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-22 10:16:39 +00:00

Remove unnecessary code.

libusbhsfs doesn't return FsFileSystem objects, that's why.
This commit is contained in:
Pablo Curiel 2020-11-21 06:29:29 -04:00
parent 2e00977f56
commit 477c321773
6 changed files with 8 additions and 72 deletions

View file

@ -69,7 +69,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lxml2 -lz -lusbhsfsd -lnx -ljson-c -lm `freetype-config --libs` -lturbojpeg
LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lxml2 -lz -lusbhsfs -lnx -ljson-c -lm `freetype-config --libs` -lturbojpeg
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing

View file

@ -1,7 +1,7 @@
#!/bin/bash
cd "$(dirname "${BASH_SOURCE[0]}")"
tar_filename="nxdumptool-rewrite_poc_$(shell git rev-parse --short HEAD).tar.bz2"
tar_filename="nxdumptool-rewrite_poc_$(git rev-parse --short HEAD).tar.bz2"
rm -f ./*.tar.bz2

View file

@ -681,7 +681,7 @@ end:
{
fclose(fd);
if (!success) utilsRemoveConcatenationFile(path);
utilsCommitFileSystemChangesByPath(path);
utilsCommitSdCardFileSystemChanges();
}
pfsFreeFileContext(&pfs_file_ctx);

View file

@ -118,7 +118,7 @@ end:
remove(path);
}
if (*path) utilsCommitFileSystemChangesByPath(path);
if (*path) utilsCommitSdCardFileSystemChanges();
pfsFreeContext(&pfs_ctx);
}
@ -194,7 +194,7 @@ end:
remove(path);
}
if (*path) utilsCommitFileSystemChangesByPath(path);
if (*path) utilsCommitSdCardFileSystemChanges();
romfsFreeContext(&romfs_ctx);
}

View file

@ -69,8 +69,6 @@ static bool _utilsIsDevelopmentUnit(void);
static bool utilsMountEmmcBisSystemPartitionStorage(void);
static void utilsUnmountEmmcBisSystemPartitionStorage(void);
static bool utilsGetDeviceFileSystemAndFilePathFromAbsolutePath(const char *path, FsFileSystem **out_fs, char **out_filepath);
static void utilsOverclockSystemAppletHook(AppletHookType hook, void *param);
bool utilsInitializeResources(void)
@ -583,46 +581,11 @@ void utilsGenerateFormattedSizeString(u64 size, char *dst, size_t dst_size)
}
}
bool utilsGetFreeSpaceFromFileSystem(FsFileSystem *fs, u64 *out)
{
if (!fs || !serviceIsActive(&(fs->s)) || !out)
{
LOGFILE("Invalid parameters!");
return false;
}
Result rc = fsFsGetFreeSpace(fs, "/", (s64*)out);
if (R_FAILED(rc)) LOGFILE("fsFsGetFreeSpace failed! (0x%08X).", rc);
return R_SUCCEEDED(rc);
}
bool utilsGetFreeSpaceFromFileSystemByPath(const char *path, u64 *out)
{
FsFileSystem *fs = NULL;
if (!utilsGetDeviceFileSystemAndFilePathFromAbsolutePath(path, &fs, NULL) || !out)
{
LOGFILE("Invalid parameters!");
return false;
}
return utilsGetFreeSpaceFromFileSystem(fs, out);
}
bool utilsGetFreeSdCardFileSystemSpace(u64 *out)
{
return utilsGetFreeSpaceFromFileSystem(g_sdCardFileSystem, out);
}
bool utilsCommitFileSystemChangesByPath(const char *path)
{
Result rc = 0;
FsFileSystem *fs = NULL;
if (!utilsGetDeviceFileSystemAndFilePathFromAbsolutePath(path, &fs, NULL)) return false;
rc = fsFsCommit(fs);
if (!g_sdCardFileSystem) return false;
Result rc = fsFsGetFreeSpace(g_sdCardFileSystem, "/", (s64*)out);
if (R_FAILED(rc)) LOGFILE("fsFsGetFreeSpace failed! (0x%08X).", rc);
return R_SUCCEEDED(rc);
}
@ -670,8 +633,6 @@ bool utilsCreateConcatenationFile(const char *path)
Result rc = fsdevCreateFile(path, 0, FsCreateOption_BigFile);
if (R_FAILED(rc)) LOGFILE("fsdevCreateFile failed for \"%s\"! (0x%08X).", path, rc);
utilsCommitFileSystemChangesByPath(path);
return R_SUCCEEDED(rc);
}
@ -696,8 +657,6 @@ void utilsCreateDirectoryTree(const char *path, bool create_last_element)
if (create_last_element) mkdir(path, 0777);
free(tmp);
utilsCommitFileSystemChangesByPath(path);
}
char *utilsGeneratePath(const char *prefix, const char *filename, const char *extension)
@ -861,25 +820,6 @@ static void utilsUnmountEmmcBisSystemPartitionStorage(void)
}
}
static bool utilsGetDeviceFileSystemAndFilePathFromAbsolutePath(const char *path, FsFileSystem **out_fs, char **out_filepath)
{
FsFileSystem *fs = NULL;
char *name_end = NULL, *filepath = NULL, name[32] = {0};
if (!path || !*path || !(name_end = strchr(path, ':')) || (size_t)(name_end - path) >= MAX_ELEMENTS(name) || (!out_fs && !out_filepath) || \
(out_filepath && *(filepath = (name_end + 1)) != '/')) return false;
sprintf(name, "%.*s", (int)(name_end - path), path);
fs = fsdevGetDeviceFileSystem(name);
if (!fs) return false;
if (out_fs) *out_fs = fs;
if (out_filepath) *out_filepath = filepath;
return true;
}
static void utilsOverclockSystemAppletHook(AppletHookType hook, void *param)
{
(void)param;

View file

@ -102,11 +102,7 @@ void utilsGenerateHexStringFromData(char *dst, size_t dst_size, const void *src,
void utilsGenerateFormattedSizeString(u64 size, char *dst, size_t dst_size);
bool utilsGetFreeSpaceFromFileSystem(FsFileSystem *fs, u64 *out);
bool utilsGetFreeSpaceFromFileSystemByPath(const char *path, u64 *out);
bool utilsGetFreeSdCardFileSystemSpace(u64 *out);
bool utilsCommitFileSystemChangesByPath(const char *path);
bool utilsCommitSdCardFileSystemChanges(void);
bool utilsCheckIfFileExists(const char *path);