mirror of
https://github.com/wiiu-env/RPXLoadingModule.git
synced 2024-06-01 18:08:50 +02:00
Formatting and cleanup
This commit is contained in:
parent
0797cb9b9a
commit
85838b1a42
|
@ -130,7 +130,8 @@ DECL_FUNCTION(int32_t, FSReadFile, FSClient *client, FSCmdBlock *block, void *bu
|
||||||
return real_FSReadFile(client, block, buffer, size, count, handle, unk1, errorMask);
|
return real_FSReadFile(client, block, buffer, size, count, handle, unk1, errorMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
DECL_FUNCTION(int32_t, FSReadFileAsync, FSClient *client, FSCmdBlock *block, void *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
DECL_FUNCTION(int32_t, FSReadFileAsync, FSClient *client, FSCmdBlock *block, void *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, FSErrorFlag errorMask,
|
||||||
|
FSAsyncData *asyncData) {
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("");
|
DEBUG_FUNCTION_LINE_VERBOSE("");
|
||||||
FSStatus result = FSReadFileWrapper(buffer, size, count, handle, unk1, errorMask, ASYNC_RESULT_HANDLER);
|
FSStatus result = FSReadFileWrapper(buffer, size, count, handle, unk1, errorMask, ASYNC_RESULT_HANDLER);
|
||||||
if (result != FS_STATUS_USE_REAL_OS) {
|
if (result != FS_STATUS_USE_REAL_OS) {
|
||||||
|
@ -152,7 +153,8 @@ DECL_FUNCTION(FSStatus, FSReadFileWithPos, FSClient *client, FSCmdBlock *block,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECL_FUNCTION(int32_t, FSReadFileWithPosAsync, FSClient *client, FSCmdBlock *block, void *buffer, uint32_t size, uint32_t count, uint32_t pos, FSFileHandle handle, int32_t unk1, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
DECL_FUNCTION(int32_t, FSReadFileWithPosAsync, FSClient *client, FSCmdBlock *block, void *buffer, uint32_t size, uint32_t count, uint32_t pos, FSFileHandle handle, int32_t unk1, FSErrorFlag errorMask,
|
||||||
|
FSAsyncData *asyncData) {
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("");
|
DEBUG_FUNCTION_LINE_VERBOSE("");
|
||||||
FSStatus result = FSReadFileWithPosWrapper(buffer, size, count, pos, handle, unk1, errorMask, ASYNC_RESULT_HANDLER);
|
FSStatus result = FSReadFileWithPosWrapper(buffer, size, count, pos, handle, unk1, errorMask, ASYNC_RESULT_HANDLER);
|
||||||
if (result != FS_STATUS_USE_REAL_OS) {
|
if (result != FS_STATUS_USE_REAL_OS) {
|
||||||
|
@ -228,7 +230,8 @@ DECL_FUNCTION(FSStatus, FSWriteFile, FSClient *client, FSCmdBlock *block, uint8_
|
||||||
return real_FSWriteFile(client, block, buffer, size, count, handle, unk1, errorMask);
|
return real_FSWriteFile(client, block, buffer, size, count, handle, unk1, errorMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
DECL_FUNCTION(FSStatus, FSWriteFileAsync, FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
DECL_FUNCTION(FSStatus, FSWriteFileAsync, FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, FSErrorFlag errorMask,
|
||||||
|
FSAsyncData *asyncData) {
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("");
|
DEBUG_FUNCTION_LINE_VERBOSE("");
|
||||||
FSStatus result = FSWriteFileWrapper(buffer, size, count, handle, unk1, errorMask, ASYNC_RESULT_HANDLER);
|
FSStatus result = FSWriteFileWrapper(buffer, size, count, handle, unk1, errorMask, ASYNC_RESULT_HANDLER);
|
||||||
if (result != FS_STATUS_USE_REAL_OS) {
|
if (result != FS_STATUS_USE_REAL_OS) {
|
||||||
|
|
|
@ -28,8 +28,8 @@ inline void getFullPath(char *pathForCheck, int pathSize, char *path) {
|
||||||
strncat(pathForCheck, path, pathSize - 1);
|
strncat(pathForCheck, path, pathSize - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < strlen(pathForCheck);i++){
|
for (int i = 0; i < strlen(pathForCheck); i++) {
|
||||||
if(pathForCheck[i] == '\\'){
|
if (pathForCheck[i] == '\\') {
|
||||||
pathForCheck[i] = '/';
|
pathForCheck[i] = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ bool isValidFileHandle(int32_t handle) {
|
||||||
|
|
||||||
int32_t getNewDirHandleIndex() {
|
int32_t getNewDirHandleIndex() {
|
||||||
dir_handle_mutex.lock();
|
dir_handle_mutex.lock();
|
||||||
int32_t handle_id;
|
int32_t handle_id = -1;
|
||||||
for (int i = 0; i < DIR_HANDLES_LENGTH; i++) {
|
for (int i = 0; i < DIR_HANDLES_LENGTH; i++) {
|
||||||
if (!dir_handles[i].in_use) {
|
if (!dir_handles[i].in_use) {
|
||||||
handle_id = i;
|
handle_id = i;
|
||||||
|
@ -137,8 +137,8 @@ void freeDirHandle(uint32_t handle) {
|
||||||
FSStatus FSOpenDirWrapper(char *path,
|
FSStatus FSOpenDirWrapper(char *path,
|
||||||
FSDirectoryHandle *handle,
|
FSDirectoryHandle *handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
const std::function<FSStatus(char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
|
@ -201,7 +201,7 @@ FSStatus FSOpenDirWrapper(char *path,
|
||||||
FSStatus FSReadDirWrapper(FSDirectoryHandle handle,
|
FSStatus FSReadDirWrapper(FSDirectoryHandle handle,
|
||||||
FSDirectoryEntry *entry,
|
FSDirectoryEntry *entry,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
|
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
|
@ -222,7 +222,7 @@ FSStatus FSReadDirWrapper(FSDirectoryHandle handle,
|
||||||
FSStatus result = FS_STATUS_END;
|
FSStatus result = FS_STATUS_END;
|
||||||
if (entry_) {
|
if (entry_) {
|
||||||
entry->name[0] = '\0';
|
entry->name[0] = '\0';
|
||||||
strncat(entry->name, entry_->d_name, sizeof(entry->name)-1);
|
strncat(entry->name, entry_->d_name, sizeof(entry->name) - 1);
|
||||||
entry->info.mode = (FSMode) FS_MODE_READ_OWNER;
|
entry->info.mode = (FSMode) FS_MODE_READ_OWNER;
|
||||||
if (entry_->d_type == DT_DIR) {
|
if (entry_->d_type == DT_DIR) {
|
||||||
entry->info.flags = (FSStatFlags) ((uint32_t) FS_STAT_DIRECTORY);
|
entry->info.flags = (FSStatFlags) ((uint32_t) FS_STAT_DIRECTORY);
|
||||||
|
@ -253,7 +253,7 @@ FSStatus FSReadDirWrapper(FSDirectoryHandle handle,
|
||||||
|
|
||||||
FSStatus FSCloseDirWrapper(FSDirectoryHandle handle,
|
FSStatus FSCloseDirWrapper(FSDirectoryHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
!isValidDirHandle(handle)) {
|
!isValidDirHandle(handle)) {
|
||||||
|
@ -281,7 +281,7 @@ FSStatus FSCloseDirWrapper(FSDirectoryHandle handle,
|
||||||
|
|
||||||
FSStatus FSRewindDirWrapper(FSDirectoryHandle handle,
|
FSStatus FSRewindDirWrapper(FSDirectoryHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
!isValidDirHandle(handle)) {
|
!isValidDirHandle(handle)) {
|
||||||
|
@ -303,8 +303,8 @@ FSStatus FSRewindDirWrapper(FSDirectoryHandle handle,
|
||||||
|
|
||||||
FSStatus FSMakeDirWrapper(char *path,
|
FSStatus FSMakeDirWrapper(char *path,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
const std::function<FSStatus(char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
||||||
|
@ -334,8 +334,8 @@ FSStatus FSOpenFileWrapper(char *path,
|
||||||
const char *mode,
|
const char *mode,
|
||||||
FSFileHandle *handle,
|
FSFileHandle *handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
const std::function<FSStatus(char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
|
@ -424,7 +424,7 @@ FSStatus FSOpenFileWrapper(char *path,
|
||||||
|
|
||||||
FSStatus FSCloseFileWrapper(FSFileHandle handle,
|
FSStatus FSCloseFileWrapper(FSFileHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
!isValidFileHandle(handle)) {
|
!isValidFileHandle(handle)) {
|
||||||
|
@ -456,8 +456,8 @@ FSStatus FSCloseFileWrapper(FSFileHandle handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
FSStatus FSGetStatWrapper(char *path, FSStat *stats, FSErrorFlag errorMask,
|
FSStatus FSGetStatWrapper(char *path, FSStat *stats, FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
const std::function<FSStatus(char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
|
@ -521,7 +521,7 @@ static inline void replaceContentPath(char *pathForCheck, int pathForCheckSize,
|
||||||
pathForCheck[0] = '\0';
|
pathForCheck[0] = '\0';
|
||||||
strncat(pathForCheck, replaceWith, sizeof(pathForCheck) - 1);
|
strncat(pathForCheck, replaceWith, sizeof(pathForCheck) - 1);
|
||||||
} else {
|
} else {
|
||||||
char pathCopy[subStrLen+1];
|
char pathCopy[subStrLen + 1];
|
||||||
pathCopy[0] = '\0';
|
pathCopy[0] = '\0';
|
||||||
strncat(pathCopy, &pathForCheck[skipLen], sizeof(pathCopy) - 1);
|
strncat(pathCopy, &pathForCheck[skipLen], sizeof(pathCopy) - 1);
|
||||||
snprintf(pathForCheck, pathForCheckSize, "%s%s", replaceWith, pathCopy);
|
snprintf(pathForCheck, pathForCheckSize, "%s%s", replaceWith, pathCopy);
|
||||||
|
@ -531,7 +531,7 @@ static inline void replaceContentPath(char *pathForCheck, int pathForCheckSize,
|
||||||
FSStatus FSGetStatFileWrapper(FSFileHandle handle,
|
FSStatus FSGetStatFileWrapper(FSFileHandle handle,
|
||||||
FSStat *stats,
|
FSStat *stats,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
!isValidFileHandle(handle)) {
|
!isValidFileHandle(handle)) {
|
||||||
|
@ -574,7 +574,7 @@ FSStatus FSReadFileWrapper(void *buffer,
|
||||||
FSFileHandle handle,
|
FSFileHandle handle,
|
||||||
uint32_t unk1,
|
uint32_t unk1,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
!isValidFileHandle(handle)) {
|
!isValidFileHandle(handle)) {
|
||||||
|
@ -621,7 +621,7 @@ FSStatus FSReadFileWithPosWrapper(void *buffer,
|
||||||
FSFileHandle handle,
|
FSFileHandle handle,
|
||||||
int32_t unk1,
|
int32_t unk1,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
!isValidFileHandle(handle)) {
|
!isValidFileHandle(handle)) {
|
||||||
|
@ -648,7 +648,7 @@ FSStatus FSReadFileWithPosWrapper(void *buffer,
|
||||||
FSStatus FSSetPosFileWrapper(FSFileHandle handle,
|
FSStatus FSSetPosFileWrapper(FSFileHandle handle,
|
||||||
uint32_t pos,
|
uint32_t pos,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
!isValidFileHandle(handle)) {
|
!isValidFileHandle(handle)) {
|
||||||
|
@ -680,7 +680,7 @@ FSStatus FSSetPosFileWrapper(FSFileHandle handle,
|
||||||
FSStatus FSGetPosFileWrapper(FSFileHandle handle,
|
FSStatus FSGetPosFileWrapper(FSFileHandle handle,
|
||||||
uint32_t *pos,
|
uint32_t *pos,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
!isValidFileHandle(handle)) {
|
!isValidFileHandle(handle)) {
|
||||||
|
@ -713,7 +713,7 @@ FSStatus FSGetPosFileWrapper(FSFileHandle handle,
|
||||||
|
|
||||||
FSStatus FSIsEofWrapper(FSFileHandle handle,
|
FSStatus FSIsEofWrapper(FSFileHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
!isValidFileHandle(handle)) {
|
!isValidFileHandle(handle)) {
|
||||||
|
@ -749,7 +749,7 @@ FSStatus FSIsEofWrapper(FSFileHandle handle,
|
||||||
|
|
||||||
FSStatus FSTruncateFileWrapper(FSFileHandle handle,
|
FSStatus FSTruncateFileWrapper(FSFileHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
|
@ -775,7 +775,7 @@ FSStatus FSWriteFileWrapper(uint8_t *buffer,
|
||||||
FSFileHandle handle,
|
FSFileHandle handle,
|
||||||
uint32_t unk1,
|
uint32_t unk1,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
|
||||||
|
@ -791,8 +791,8 @@ FSStatus FSWriteFileWrapper(uint8_t *buffer,
|
||||||
|
|
||||||
FSStatus FSRemoveWrapper(char *path,
|
FSStatus FSRemoveWrapper(char *path,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
const std::function<FSStatus(char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
||||||
|
@ -822,8 +822,8 @@ FSStatus FSRemoveWrapper(char *path,
|
||||||
FSStatus FSRenameWrapper(char *oldPath,
|
FSStatus FSRenameWrapper(char *oldPath,
|
||||||
char *newPath,
|
char *newPath,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_oldPath, char *_newPath)> fallback_function,
|
const std::function<FSStatus(char *, char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
||||||
|
@ -852,7 +852,7 @@ FSStatus FSRenameWrapper(char *oldPath,
|
||||||
return result_handler(result);
|
return result_handler(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
FSStatus FSFlushFileWrapper(FSFileHandle handle, FSErrorFlag errorMask, std::function<FSStatus(FSStatus)> result_handler) {
|
FSStatus FSFlushFileWrapper(FSFileHandle handle, FSErrorFlag errorMask, const std::function<FSStatus(FSStatus)>& result_handler) {
|
||||||
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
|
||||||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {
|
||||||
|
|
|
@ -37,48 +37,48 @@ extern fileMagic_t file_handles[FILE_HANDLES_LENGTH];
|
||||||
FSStatus FSOpenDirWrapper(char *path,
|
FSStatus FSOpenDirWrapper(char *path,
|
||||||
FSDirectoryHandle *handle,
|
FSDirectoryHandle *handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
const std::function<FSStatus(char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSReadDirWrapper(FSDirectoryHandle handle,
|
FSStatus FSReadDirWrapper(FSDirectoryHandle handle,
|
||||||
FSDirectoryEntry *entry,
|
FSDirectoryEntry *entry,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSCloseDirWrapper(FSDirectoryHandle handle,
|
FSStatus FSCloseDirWrapper(FSDirectoryHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSRewindDirWrapper(FSDirectoryHandle handle,
|
FSStatus FSRewindDirWrapper(FSDirectoryHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSMakeDirWrapper(char *path,
|
FSStatus FSMakeDirWrapper(char *path,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
const std::function<FSStatus(char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSOpenFileWrapper(char *path,
|
FSStatus FSOpenFileWrapper(char *path,
|
||||||
const char *mode,
|
const char *mode,
|
||||||
FSFileHandle *handle,
|
FSFileHandle *handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
const std::function<FSStatus(char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSCloseFileWrapper(FSFileHandle handle,
|
FSStatus FSCloseFileWrapper(FSFileHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSGetStatWrapper(char *path,
|
FSStatus FSGetStatWrapper(char *path,
|
||||||
FSStat *stats,
|
FSStat *stats,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
const std::function<FSStatus(char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSGetStatFileWrapper(FSFileHandle handle,
|
FSStatus FSGetStatFileWrapper(FSFileHandle handle,
|
||||||
FSStat *stats,
|
FSStat *stats,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSReadFileWrapper(void *buffer,
|
FSStatus FSReadFileWrapper(void *buffer,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
|
@ -86,7 +86,7 @@ FSStatus FSReadFileWrapper(void *buffer,
|
||||||
FSFileHandle handle,
|
FSFileHandle handle,
|
||||||
uint32_t unk1,
|
uint32_t unk1,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSReadFileWithPosWrapper(void *buffer,
|
FSStatus FSReadFileWithPosWrapper(void *buffer,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
|
@ -95,25 +95,25 @@ FSStatus FSReadFileWithPosWrapper(void *buffer,
|
||||||
FSFileHandle handle,
|
FSFileHandle handle,
|
||||||
int32_t unk1,
|
int32_t unk1,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSSetPosFileWrapper(FSFileHandle handle,
|
FSStatus FSSetPosFileWrapper(FSFileHandle handle,
|
||||||
uint32_t pos,
|
uint32_t pos,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSGetPosFileWrapper(FSFileHandle handle,
|
FSStatus FSGetPosFileWrapper(FSFileHandle handle,
|
||||||
uint32_t *pos,
|
uint32_t *pos,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSIsEofWrapper(FSFileHandle handle,
|
FSStatus FSIsEofWrapper(FSFileHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSTruncateFileWrapper(FSFileHandle handle,
|
FSStatus FSTruncateFileWrapper(FSFileHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSWriteFileWrapper(uint8_t *buffer,
|
FSStatus FSWriteFileWrapper(uint8_t *buffer,
|
||||||
uint32_t size,
|
uint32_t size,
|
||||||
|
@ -121,22 +121,22 @@ FSStatus FSWriteFileWrapper(uint8_t *buffer,
|
||||||
FSFileHandle handle,
|
FSFileHandle handle,
|
||||||
uint32_t unk1,
|
uint32_t unk1,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSRemoveWrapper(char *path,
|
FSStatus FSRemoveWrapper(char *path,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
const std::function<FSStatus(char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSRenameWrapper(char *oldPath,
|
FSStatus FSRenameWrapper(char *oldPath,
|
||||||
char *newPath,
|
char *newPath,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_oldPath, char *_newPath)> fallback_function,
|
const std::function<FSStatus(char *, char *)>& fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
FSStatus FSFlushFileWrapper(FSFileHandle handle,
|
FSStatus FSFlushFileWrapper(FSFileHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler);
|
const std::function<FSStatus(FSStatus)>& result_handler);
|
||||||
|
|
||||||
int32_t getNewDirHandleIndex();
|
int32_t getNewDirHandleIndex();
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ int32_t readIntoBuffer(int32_t handle, void *buffer, size_t size, size_t count)
|
||||||
return totalSize;
|
return totalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CheckFile(const char * filepath) {
|
int32_t CheckFile(const char *filepath) {
|
||||||
if (!filepath) {
|
if (!filepath) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -117,33 +117,33 @@ int32_t CheckFile(const char * filepath) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CreateSubfolder(const char * fullpath) {
|
int32_t CreateSubfolder(const char *fullpath) {
|
||||||
if(!fullpath)
|
if (!fullpath)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
|
|
||||||
char dirnoslash[strlen(fullpath)+1];
|
char dirnoslash[strlen(fullpath) + 1];
|
||||||
strcpy(dirnoslash, fullpath);
|
strcpy(dirnoslash, fullpath);
|
||||||
|
|
||||||
int32_t pos = strlen(dirnoslash)-1;
|
int32_t pos = strlen(dirnoslash) - 1;
|
||||||
while(dirnoslash[pos] == '/') {
|
while (dirnoslash[pos] == '/') {
|
||||||
dirnoslash[pos] = '\0';
|
dirnoslash[pos] = '\0';
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CheckFile(dirnoslash)) {
|
if (CheckFile(dirnoslash)) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
char parentpath[strlen(dirnoslash)+2];
|
char parentpath[strlen(dirnoslash) + 2];
|
||||||
strcpy(parentpath, dirnoslash);
|
strcpy(parentpath, dirnoslash);
|
||||||
char * ptr = strrchr(parentpath, '/');
|
char *ptr = strrchr(parentpath, '/');
|
||||||
|
|
||||||
if(!ptr) {
|
if (!ptr) {
|
||||||
//!Device root directory (must be with '/')
|
//!Device root directory (must be with '/')
|
||||||
strcat(parentpath, "/");
|
strcat(parentpath, "/");
|
||||||
struct stat filestat{};
|
struct stat filestat{};
|
||||||
if (stat(parentpath, &filestat) == 0){
|
if (stat(parentpath, &filestat) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ int32_t getRPXInfoForPath(const std::string &path, romfs_fileInfo *info) {
|
||||||
if (romfsGetFileInfoPerPath("rcc", (std::string("code/") + entry->d_name).c_str(), info) >= 0) {
|
if (romfsGetFileInfoPerPath("rcc", (std::string("code/") + entry->d_name).c_str(), info) >= 0) {
|
||||||
found = true;
|
found = true;
|
||||||
res = 0;
|
res = 0;
|
||||||
}else{
|
} else {
|
||||||
DEBUG_FUNCTION_LINE("Failed to get info for %s", entry->d_name);
|
DEBUG_FUNCTION_LINE("Failed to get info for %s", entry->d_name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,4 +23,4 @@ int32_t CreateSubfolder(const char *fullpath);
|
||||||
|
|
||||||
int32_t getRPXInfoForPath(const std::string &path, romfs_fileInfo *info);
|
int32_t getRPXInfoForPath(const std::string &path, romfs_fileInfo *info);
|
||||||
|
|
||||||
int32_t CheckFile(const char * filepath);
|
int32_t CheckFile(const char *filepath);
|
|
@ -77,7 +77,6 @@ DECL_FUNCTION(FSStatus, RPX_FSCloseFile, FSClient *client, FSCmdBlock *block, FS
|
||||||
}
|
}
|
||||||
|
|
||||||
DECL_FUNCTION(void, Loader_ReportWarn) {
|
DECL_FUNCTION(void, Loader_ReportWarn) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function_replacement_data_t rpx_utils_function_replacements[] = {
|
function_replacement_data_t rpx_utils_function_replacements[] = {
|
||||||
|
@ -285,7 +284,7 @@ bool RL_FileExists(const char *name) {
|
||||||
return CheckFile(name) || CheckFile(checkgz.c_str());
|
return CheckFile(name) || CheckFile(checkgz.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RL_RedirectContentWithFallback(const char * newContentPath) {
|
bool RL_RedirectContentWithFallback(const char *newContentPath) {
|
||||||
auto dirHandle = opendir(newContentPath);
|
auto dirHandle = opendir(newContentPath);
|
||||||
if (dirHandle == nullptr) {
|
if (dirHandle == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -25,7 +25,7 @@ int FileReader::read(uint8_t *buffer, uint32_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileReader::FileReader(std::string &path) {
|
FileReader::FileReader(std::string &path) {
|
||||||
int fd = -1;
|
int fd;
|
||||||
if ((fd = open(path.c_str(), O_RDONLY)) >= 0) {
|
if ((fd = open(path.c_str(), O_RDONLY)) >= 0) {
|
||||||
this->isReadFromFile = true;
|
this->isReadFromFile = true;
|
||||||
this->isReadFromBuffer = false;
|
this->isReadFromBuffer = false;
|
||||||
|
|
|
@ -10,11 +10,12 @@ class FileReader {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FileReader(uint8_t *buffer, uint32_t size);
|
FileReader(uint8_t *buffer, uint32_t size);
|
||||||
|
|
||||||
explicit FileReader(std::string &path);
|
explicit FileReader(std::string &path);
|
||||||
|
|
||||||
virtual ~FileReader();
|
virtual ~FileReader();
|
||||||
|
|
||||||
virtual int read(uint8_t *buffer, uint32_t size) ;
|
virtual int read(uint8_t *buffer, uint32_t size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isReadFromBuffer = false;
|
bool isReadFromBuffer = false;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#include "FileReaderCompressed.h"
|
#include "FileReaderCompressed.h"
|
||||||
|
|
||||||
int FileReaderCompressed::read(uint8_t *buffer, uint32_t size) {
|
int FileReaderCompressed::read(uint8_t *buffer, uint32_t size) {
|
||||||
|
if(!initDone){
|
||||||
|
return -11;
|
||||||
|
}
|
||||||
int startValue = this->strm.total_out;
|
int startValue = this->strm.total_out;
|
||||||
uint32_t newSize = 0;
|
uint32_t newSize = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
|
@ -12,7 +12,7 @@ public:
|
||||||
|
|
||||||
explicit FileReaderCompressed(std::string &file);
|
explicit FileReaderCompressed(std::string &file);
|
||||||
|
|
||||||
~FileReaderCompressed() override{
|
~FileReaderCompressed() override {
|
||||||
DEBUG_FUNCTION_LINE("");
|
DEBUG_FUNCTION_LINE("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,122 +0,0 @@
|
||||||
/**
|
|
||||||
* The contents of this file are based on the article posted at the
|
|
||||||
* following location:
|
|
||||||
*
|
|
||||||
* http://crascit.com/2015/06/03/on-leaving-scope-part-2/
|
|
||||||
*
|
|
||||||
* The material in that article has some commonality with the code made
|
|
||||||
* available as part of Facebook's folly library at:
|
|
||||||
*
|
|
||||||
* https://github.com/facebook/folly/blob/master/folly/ScopeGuard.h
|
|
||||||
*
|
|
||||||
* Furthermore, similar material is currently part of a draft proposal
|
|
||||||
* to the C++ standards committee, referencing the same work by Andrei
|
|
||||||
* Alexandresu that led to the folly implementation. The draft proposal
|
|
||||||
* can be found at:
|
|
||||||
*
|
|
||||||
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4189.pdf
|
|
||||||
*
|
|
||||||
* With the above in mind, the content below is made available under
|
|
||||||
* the same license terms as folly to minimize any legal concerns.
|
|
||||||
* Should there be ambiguity over copyright ownership between Facebook
|
|
||||||
* and myself for any material included in this file, it should be
|
|
||||||
* interpreted that Facebook is the copyright owner for the ambiguous
|
|
||||||
* section of code concerned.
|
|
||||||
*
|
|
||||||
* Craig Scott
|
|
||||||
* 3rd June 2015
|
|
||||||
*
|
|
||||||
* ----------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* Copyright 2015 Craig Scott
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CRASCIT_ONLEAVINGSCOPE_H
|
|
||||||
#define CRASCIT_ONLEAVINGSCOPE_H
|
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is intended to be used only to create a local object on the
|
|
||||||
* stack. It accepts a function object in its constructor and will invoke
|
|
||||||
* that function object in its destructor. The class provides a move
|
|
||||||
* constructor so it can be used with the onLeavingScope factory function,
|
|
||||||
* but it cannot be copied.
|
|
||||||
*
|
|
||||||
* Do no use this function directly, use the onLeavingScope() factory
|
|
||||||
* function instead.
|
|
||||||
*/
|
|
||||||
template<typename Func>
|
|
||||||
class OnLeavingScope
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Prevent copying
|
|
||||||
OnLeavingScope(const OnLeavingScope&) = delete;
|
|
||||||
OnLeavingScope& operator=(const OnLeavingScope&) = delete;
|
|
||||||
|
|
||||||
// Allow moving
|
|
||||||
OnLeavingScope(OnLeavingScope&& other) :
|
|
||||||
m_func(std::move(other.m_func)),
|
|
||||||
m_owner(other.m_owner)
|
|
||||||
{
|
|
||||||
other.m_owner = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
OnLeavingScope(const Func& f) :
|
|
||||||
m_func(f),
|
|
||||||
m_owner(true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
OnLeavingScope(Func&& f) :
|
|
||||||
m_func(std::move(f)),
|
|
||||||
m_owner(true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
~OnLeavingScope()
|
|
||||||
{
|
|
||||||
if (m_owner)
|
|
||||||
m_func();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Func m_func;
|
|
||||||
bool m_owner;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Factory function for creating an OnLeavingScope object. It is intended
|
|
||||||
* to be used like so:
|
|
||||||
*
|
|
||||||
* auto cleanup = onLeavingScope(...);
|
|
||||||
*
|
|
||||||
* where the ... could be a lambda function, function object or pointer to
|
|
||||||
* a free function to be invoked when the cleanup object goes out of scope.
|
|
||||||
* The function object must take no function arguments, but can return any
|
|
||||||
* type (the return value is ignored).
|
|
||||||
*
|
|
||||||
* The \a Func template parameter would rarely, if ever, be manually
|
|
||||||
* specified. Normally, it would be deduced automatically by the compiler
|
|
||||||
* from the object passed as the function argument.
|
|
||||||
*/
|
|
||||||
template<typename Func>
|
|
||||||
OnLeavingScope<typename std::decay<Func>::type> onLeavingScope(Func&& f)
|
|
||||||
{
|
|
||||||
return OnLeavingScope<typename std::decay<Func>::type>(std::forward<Func>(f));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // CRASCIT_ONLEAVINGSCOPE_H
|
|
|
@ -290,7 +290,6 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* hash: compute hash value of string */
|
/* hash: compute hash value of string */
|
||||||
uint32_t StringTools::hash(char *str) {
|
uint32_t StringTools::hash(char *str) {
|
||||||
unsigned int h;
|
unsigned int h;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <whb/log.h>
|
#include <whb/log.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ extern "C" {
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
} while (0);
|
} while (0)
|
||||||
|
|
||||||
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||||
OSFatal_printf("[%s]%s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
OSFatal_printf("[%s]%s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
|
|
|
@ -1,69 +1,69 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <whb/log.h>
|
#include <whb/log.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <coreinit/debug.h>
|
#include <coreinit/debug.h>
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
#define PRINTF_BUFFER_LENGTH 2048
|
#define PRINTF_BUFFER_LENGTH 2048
|
||||||
|
|
||||||
// https://gist.github.com/ccbrown/9722406
|
// https://gist.github.com/ccbrown/9722406
|
||||||
void dumpHex(const void *data, size_t size) {
|
void dumpHex(const void *data, size_t size) {
|
||||||
char ascii[17];
|
char ascii[17];
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
ascii[16] = '\0';
|
ascii[16] = '\0';
|
||||||
DEBUG_FUNCTION_LINE("0x%08X (0x0000): ", data);
|
DEBUG_FUNCTION_LINE("0x%08X (0x0000): ", data);
|
||||||
for (i = 0; i < size; ++i) {
|
for (i = 0; i < size; ++i) {
|
||||||
WHBLogWritef("%02X ", ((unsigned char *) data)[i]);
|
WHBLogWritef("%02X ", ((unsigned char *) data)[i]);
|
||||||
if (((unsigned char *) data)[i] >= ' ' && ((unsigned char *) data)[i] <= '~') {
|
if (((unsigned char *) data)[i] >= ' ' && ((unsigned char *) data)[i] <= '~') {
|
||||||
ascii[i % 16] = ((unsigned char *) data)[i];
|
ascii[i % 16] = ((unsigned char *) data)[i];
|
||||||
} else {
|
} else {
|
||||||
ascii[i % 16] = '.';
|
ascii[i % 16] = '.';
|
||||||
}
|
}
|
||||||
if ((i + 1) % 8 == 0 || i + 1 == size) {
|
if ((i + 1) % 8 == 0 || i + 1 == size) {
|
||||||
WHBLogWritef(" ");
|
WHBLogWritef(" ");
|
||||||
if ((i + 1) % 16 == 0) {
|
if ((i + 1) % 16 == 0) {
|
||||||
WHBLogPrintf("| %s ", ascii);
|
WHBLogPrintf("| %s ", ascii);
|
||||||
if (i + 1 < size) {
|
if (i + 1 < size) {
|
||||||
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", data + i + 1, i + 1);
|
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", data + i + 1, i + 1);
|
||||||
}
|
}
|
||||||
} else if (i + 1 == size) {
|
} else if (i + 1 == size) {
|
||||||
ascii[(i + 1) % 16] = '\0';
|
ascii[(i + 1) % 16] = '\0';
|
||||||
if ((i + 1) % 16 <= 8) {
|
if ((i + 1) % 16 <= 8) {
|
||||||
WHBLogWritef(" ");
|
WHBLogWritef(" ");
|
||||||
}
|
}
|
||||||
for (j = (i + 1) % 16; j < 16; ++j) {
|
for (j = (i + 1) % 16; j < 16; ++j) {
|
||||||
WHBLogWritef(" ");
|
WHBLogWritef(" ");
|
||||||
}
|
}
|
||||||
WHBLogPrintf("| %s ", ascii);
|
WHBLogPrintf("| %s ", ascii);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL OSFatal_printf(const char *fmt, ...) {
|
BOOL OSFatal_printf(const char *fmt, ...) {
|
||||||
char *buf1 = memalign(4,PRINTF_BUFFER_LENGTH);
|
char *buf1 = (char *) memalign(4, PRINTF_BUFFER_LENGTH);
|
||||||
char *buf2 = memalign(4,PRINTF_BUFFER_LENGTH);
|
char *buf2 = (char *) memalign(4, PRINTF_BUFFER_LENGTH);
|
||||||
va_list va;
|
va_list va;
|
||||||
|
|
||||||
if (!buf1) {
|
if (!buf1) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buf2) {
|
if (!buf2) {
|
||||||
free(buf1);
|
free(buf1);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
|
|
||||||
vsnprintf(buf1, PRINTF_BUFFER_LENGTH, fmt, va);
|
vsnprintf(buf1, PRINTF_BUFFER_LENGTH, fmt, va);
|
||||||
snprintf(buf2, PRINTF_BUFFER_LENGTH, "%s\n", buf1);
|
snprintf(buf2, PRINTF_BUFFER_LENGTH, "%s\n", buf1);
|
||||||
OSFatal(buf2);
|
OSFatal(buf2);
|
||||||
|
|
||||||
free(buf1);
|
free(buf1);
|
||||||
free(buf2);
|
free(buf2);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user