Fix
This commit is contained in:
parent
85fa45201e
commit
6c530c44bd
27
external/fs.c
vendored
27
external/fs.c
vendored
@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define WORKING_DIR "/"
|
||||||
|
|
||||||
void Utils_U8_To_U16(u16 *buf, const u8 *input, size_t bufsize) {
|
void Utils_U8_To_U16(u16 *buf, const u8 *input, size_t bufsize) {
|
||||||
ssize_t units = utf8_to_utf16(buf, input, bufsize);
|
ssize_t units = utf8_to_utf16(buf, input, bufsize);
|
||||||
@ -344,6 +347,30 @@ FS_Path getPathInfo(const char * path, FS_ArchiveID * archive) {
|
|||||||
|
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
Result makeDirs(const char * path) {
|
||||||
|
Result ret = 0;
|
||||||
|
FS_ArchiveID archiveID;
|
||||||
|
FS_Path filePath = getPathInfo(path, &archiveID);
|
||||||
|
FS_Archive archive;
|
||||||
|
|
||||||
|
ret = FSUSER_OpenArchive(&archive, archiveID, fsMakePath(PATH_EMPTY, ""));
|
||||||
|
|
||||||
|
for (char * slashpos = strchr(path+1, '/'); slashpos != NULL; slashpos = strchr(slashpos+1, '/')) {
|
||||||
|
char bak = *(slashpos);
|
||||||
|
*(slashpos) = '\0';
|
||||||
|
Handle dirHandle;
|
||||||
|
|
||||||
|
ret = FSUSER_OpenDirectory(&dirHandle, archive, filePath);
|
||||||
|
if (R_SUCCEEDED(ret)) FSDIR_Close(dirHandle);
|
||||||
|
else ret = FSUSER_CreateDirectory(archive, filePath, FS_ATTRIBUTE_DIRECTORY);
|
||||||
|
|
||||||
|
*(slashpos) = bak;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSUSER_CloseArchive(archive);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
Result openFile(Handle* fileHandle, const char * path, bool write) {
|
Result openFile(Handle* fileHandle, const char * path, bool write) {
|
||||||
FS_ArchiveID archive;
|
FS_ArchiveID archive;
|
||||||
|
1
external/fs.h
vendored
1
external/fs.h
vendored
@ -26,6 +26,7 @@ Result FS_RenameDir(FS_Archive archive, const char *old_dirname, const char *new
|
|||||||
Result FS_Read(FS_Archive archive, const char *path, u64 size, void *buf);
|
Result FS_Read(FS_Archive archive, const char *path, u64 size, void *buf);
|
||||||
Result FS_Write(FS_Archive archive, const char *path, const void *buf, u32 size);
|
Result FS_Write(FS_Archive archive, const char *path, const void *buf, u32 size);
|
||||||
char *FS_GetFileTimestamp(const char *path);
|
char *FS_GetFileTimestamp(const char *path);
|
||||||
|
Result makeDirs(const char * path);
|
||||||
Result openFile(Handle* fileHandle, const char * path, bool write);
|
Result openFile(Handle* fileHandle, const char * path, bool write);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user