mirror of
https://github.com/wiiu-env/RPXLoadingModule.git
synced 2024-11-21 17:39:15 +01:00
Format the code via clang-format
This commit is contained in:
parent
91f77ed210
commit
142aa827d2
67
.clang-format
Normal file
67
.clang-format
Normal file
@ -0,0 +1,67 @@
|
||||
# Generated from CLion C/C++ Code Style settings
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: Consecutive
|
||||
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
|
||||
AlignOperands: Align
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
ColumnLimit: 0
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 8
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: All
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -6,8 +6,16 @@ on:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
|
8
.github/workflows/pr.yml
vendored
8
.github/workflows/pr.yml
vendored
@ -3,8 +3,16 @@ name: CI-PR
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
|
||||
build-binary:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
|
@ -1,3 +1,5 @@
|
||||
[![CI-Release](https://github.com/wiiu-env/RPXLoadingModule/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/RPXLoadingModule/actions/workflows/ci.yml)
|
||||
|
||||
## Usage
|
||||
(`[ENVIRONMENT]` is a placeholder for the actual environment name.)
|
||||
|
||||
@ -18,3 +20,7 @@ docker run -it --rm -v ${PWD}:/project rpxloadingmodule-builder make
|
||||
# make clean
|
||||
docker run -it --rm -v ${PWD}:/project rpxloadingmodule-builder make clean
|
||||
```
|
||||
|
||||
## Format the code via docker
|
||||
|
||||
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src -i`
|
@ -1,10 +1,10 @@
|
||||
#include "FSDirReplacements.h"
|
||||
#include <coreinit/filesystem.h>
|
||||
#include <coreinit/cache.h>
|
||||
#include "utils/logger.h"
|
||||
#include "globals.h"
|
||||
#include "FSWrapper.h"
|
||||
#include "FileUtils.h"
|
||||
#include "globals.h"
|
||||
#include "utils/logger.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/filesystem.h>
|
||||
|
||||
#define SYNC_RESULT_HANDLER [](FSStatus res) -> FSStatus { \
|
||||
return res; \
|
||||
@ -17,9 +17,9 @@
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSOpenDir, FSClient *client, FSCmdBlock *block, char *path, FSDirectoryHandle *handle, FSErrorFlag errorMask) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
|
||||
FSStatus result = FSOpenDirWrapper(path, handle, errorMask,
|
||||
[client, block, handle, errorMask]
|
||||
(char *_path) -> FSStatus {
|
||||
FSStatus result = FSOpenDirWrapper(
|
||||
path, handle, errorMask,
|
||||
[client, block, handle, errorMask](char *_path) -> FSStatus {
|
||||
return real_FSOpenDir(client, block, _path, handle, errorMask);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -37,9 +37,9 @@ DECL_FUNCTION(FSStatus, FSOpenDirAsync, FSClient *client, FSCmdBlock *block, cha
|
||||
|
||||
// Even real_FSOpenDir is still calling our FSOpenDirAsync hook. To bypass our code we use "FORCE_REAL_FUNC_WITH_FULL_ERRORS" as an errorMask.
|
||||
if ((errorMask & ERROR_FLAG_MASK) != FORCE_REAL_FUNC_MAGIC) {
|
||||
FSStatus result = FSOpenDirWrapper(path, handle, errorMask,
|
||||
[client, block, handle, errorMask, asyncData]
|
||||
(char *_path) -> FSStatus {
|
||||
FSStatus result = FSOpenDirWrapper(
|
||||
path, handle, errorMask,
|
||||
[client, block, handle, errorMask, asyncData](char *_path) -> FSStatus {
|
||||
return real_FSOpenDirAsync(client, block, _path, handle, errorMask, asyncData);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -133,9 +133,9 @@ DECL_FUNCTION(FSStatus, FSRewindDirAsync, FSClient *client, FSCmdBlock *block, F
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSMakeDir, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
|
||||
FSStatus result = FSMakeDirWrapper(path, errorMask,
|
||||
[client, block, errorMask]
|
||||
(char *_path) -> FSStatus {
|
||||
FSStatus result = FSMakeDirWrapper(
|
||||
path, errorMask,
|
||||
[client, block, errorMask](char *_path) -> FSStatus {
|
||||
return real_FSMakeDir(client, block, _path, errorMask);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -148,9 +148,9 @@ DECL_FUNCTION(FSStatus, FSMakeDir, FSClient *client, FSCmdBlock *block, char *pa
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSMakeDirAsync, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
|
||||
FSStatus result = FSMakeDirWrapper(path, errorMask,
|
||||
[client, block, errorMask, asyncData]
|
||||
(char *_path) -> FSStatus {
|
||||
FSStatus result = FSMakeDirWrapper(
|
||||
path, errorMask,
|
||||
[client, block, errorMask, asyncData](char *_path) -> FSStatus {
|
||||
return real_FSMakeDirAsync(client, block, _path, errorMask, asyncData);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -163,7 +163,7 @@ DECL_FUNCTION(FSStatus, FSMakeDirAsync, FSClient *client, FSCmdBlock *block, cha
|
||||
DECL_FUNCTION(FSStatus, FSChangeDirAsync, FSClient *client, FSCmdBlock *block, const char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("FSChangeDirAsync %s", path);
|
||||
snprintf(gReplacementInfo.contentReplacementInfo.workingDir, sizeof(gReplacementInfo.contentReplacementInfo.workingDir), "%s", path);
|
||||
int len = strlen(gReplacementInfo.contentReplacementInfo.workingDir);
|
||||
auto len = strlen(gReplacementInfo.contentReplacementInfo.workingDir);
|
||||
if (len > 0 && gReplacementInfo.contentReplacementInfo.workingDir[len - 1] != '/') {
|
||||
gReplacementInfo.contentReplacementInfo.workingDir[len - 1] = '/';
|
||||
gReplacementInfo.contentReplacementInfo.workingDir[len] = 0;
|
||||
|
@ -13,4 +13,3 @@ extern uint32_t fs_dir_function_replacements_size;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include <coreinit/dynload.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "utils/logger.h"
|
||||
#include "FileUtils.h"
|
||||
#include "FSWrapper.h"
|
||||
#include "FileUtils.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
#define SYNC_RESULT_HANDLER [](FSStatus res) -> FSStatus { \
|
||||
return res; \
|
||||
@ -18,9 +18,9 @@
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, FSFileHandle *handle, FSErrorFlag errorMask) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
|
||||
FSStatus result = FSOpenFileWrapper(path, mode, handle, errorMask,
|
||||
[client, block, mode, handle, errorMask]
|
||||
(char *_path) -> FSStatus {
|
||||
FSStatus result = FSOpenFileWrapper(
|
||||
path, mode, handle, errorMask,
|
||||
[client, block, mode, handle, errorMask](char *_path) -> FSStatus {
|
||||
return real_FSOpenFile(client, block, _path, mode, handle, errorMask);
|
||||
},
|
||||
SYNC_RESULT_HANDLER);
|
||||
@ -34,9 +34,9 @@ DECL_FUNCTION(FSStatus, FSOpenFile, FSClient *client, FSCmdBlock *block, char *p
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSOpenFileAsync, FSClient *client, FSCmdBlock *block, char *path, const char *mode, FSFileHandle *handle, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
|
||||
FSStatus result = FSOpenFileWrapper(path, mode, handle, errorMask,
|
||||
[client, block, mode, handle, errorMask, asyncData]
|
||||
(char *_path) -> FSStatus {
|
||||
FSStatus result = FSOpenFileWrapper(
|
||||
path, mode, handle, errorMask,
|
||||
[client, block, mode, handle, errorMask, asyncData](char *_path) -> FSStatus {
|
||||
return real_FSOpenFileAsync(client, block, _path, mode, handle, errorMask, asyncData);
|
||||
},
|
||||
ASYNC_RESULT_HANDLER);
|
||||
@ -70,7 +70,8 @@ DECL_FUNCTION(FSStatus, FSCloseFileAsync, FSClient *client, FSCmdBlock *block, F
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSGetStat, FSClient *client, FSCmdBlock *block, char *path, FSStat *stats, FSErrorFlag errorMask) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
|
||||
FSStatus result = FSGetStatWrapper(path, stats, errorMask,
|
||||
FSStatus result = FSGetStatWrapper(
|
||||
path, stats, errorMask,
|
||||
[client, block, stats, errorMask](char *_path) -> FSStatus {
|
||||
return real_FSGetStat(client, block, _path, stats, errorMask);
|
||||
},
|
||||
@ -83,7 +84,8 @@ DECL_FUNCTION(FSStatus, FSGetStat, FSClient *client, FSCmdBlock *block, char *pa
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSGetStatAsync, FSClient *client, FSCmdBlock *block, char *path, FSStat *stats, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
|
||||
FSStatus result = FSGetStatWrapper(path, stats, errorMask,
|
||||
FSStatus result = FSGetStatWrapper(
|
||||
path, stats, errorMask,
|
||||
[client, block, stats, errorMask, asyncData](char *_path) -> FSStatus {
|
||||
return real_FSGetStatAsync(client, block, _path, stats, errorMask, asyncData);
|
||||
},
|
||||
@ -257,7 +259,8 @@ DECL_FUNCTION(FSStatus, FSTruncateFileAsync, FSClient *client, FSCmdBlock *block
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSRemove, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
|
||||
FSStatus result = FSRemoveWrapper(path, errorMask,
|
||||
FSStatus result = FSRemoveWrapper(
|
||||
path, errorMask,
|
||||
[client, block, errorMask](char *_path) -> FSStatus {
|
||||
return real_FSRemove(client, block, _path, errorMask);
|
||||
},
|
||||
@ -271,7 +274,8 @@ DECL_FUNCTION(FSStatus, FSRemove, FSClient *client, FSCmdBlock *block, char *pat
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSRemoveAsync, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
|
||||
FSStatus result = FSRemoveWrapper(path, errorMask,
|
||||
FSStatus result = FSRemoveWrapper(
|
||||
path, errorMask,
|
||||
[client, block, errorMask, asyncData](char *_path) -> FSStatus {
|
||||
return real_FSRemoveAsync(client, block, _path, errorMask, asyncData);
|
||||
},
|
||||
@ -285,7 +289,8 @@ DECL_FUNCTION(FSStatus, FSRemoveAsync, FSClient *client, FSCmdBlock *block, char
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSRename, FSClient *client, FSCmdBlock *block, char *oldPath, char *newPath, FSErrorFlag errorMask) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s %s", oldPath, newPath);
|
||||
FSStatus result = FSRenameWrapper(oldPath, newPath, errorMask,
|
||||
FSStatus result = FSRenameWrapper(
|
||||
oldPath, newPath, errorMask,
|
||||
[client, block, errorMask](char *_oldOath, char *_newPath) -> FSStatus {
|
||||
return real_FSRename(client, block, _oldOath, _newPath, errorMask);
|
||||
},
|
||||
@ -299,7 +304,8 @@ DECL_FUNCTION(FSStatus, FSRename, FSClient *client, FSCmdBlock *block, char *old
|
||||
|
||||
DECL_FUNCTION(FSStatus, FSRenameAsync, FSClient *client, FSCmdBlock *block, char *oldPath, char *newPath, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("%s %s", oldPath, newPath);
|
||||
FSStatus result = FSRenameWrapper(oldPath, newPath, errorMask,
|
||||
FSStatus result = FSRenameWrapper(
|
||||
oldPath, newPath, errorMask,
|
||||
[client, block, errorMask, asyncData](char *_oldOath, char *_newPath) -> FSStatus {
|
||||
return real_FSRenameAsync(client, block, _oldOath, _newPath, errorMask, asyncData);
|
||||
},
|
||||
|
@ -13,4 +13,3 @@ extern uint32_t fs_file_function_replacements_size;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include "FSWrapper.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include "utils/logger.h"
|
||||
#include "FileUtils.h"
|
||||
#include "globals.h"
|
||||
#include "utils/logger.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <mutex>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
dirMagic_t dir_handles[DIR_HANDLES_LENGTH];
|
||||
fileMagic_t file_handles[FILE_HANDLES_LENGTH];
|
||||
@ -59,10 +59,10 @@ int getNewFileHandleIndex() {
|
||||
handle_id = i;
|
||||
if (!file_handles[i].mutex) {
|
||||
file_handles[i].mutex = (OSMutex *) malloc(sizeof(OSMutex));
|
||||
OSInitMutex(file_handles[i].mutex);
|
||||
if (!file_handles[i].mutex) {
|
||||
OSFatal("Failed to alloc memory for mutex");
|
||||
}
|
||||
OSInitMutex(file_handles[i].mutex);
|
||||
DCFlushRange(file_handles[i].mutex, sizeof(OSMutex));
|
||||
DCFlushRange(&file_handles[i], sizeof(fileMagic_t));
|
||||
}
|
||||
@ -779,14 +779,12 @@ FSStatus FSReadFileWithPosWrapper(void *buffer,
|
||||
|
||||
FSStatus result;
|
||||
if ((result = FSSetPosFileWrapper(handle, pos, errorMask,
|
||||
[](FSStatus res) -> FSStatus { return res; })
|
||||
) != FS_STATUS_OK) {
|
||||
[](FSStatus res) -> FSStatus { return res; })) != FS_STATUS_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = FSReadFileWrapper(buffer, size, count, handle, unk1, errorMask,
|
||||
[](FSStatus res) -> FSStatus { return res; }
|
||||
);
|
||||
[](FSStatus res) -> FSStatus { return res; });
|
||||
|
||||
if (result != FS_STATUS_USE_REAL_OS && result != FS_STATUS_FATAL_ERROR) {
|
||||
return result_handler(result);
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <coreinit/filesystem.h>
|
||||
#include <coreinit/mutex.h>
|
||||
#include <cstdint>
|
||||
#include <dirent.h>
|
||||
#include <functional>
|
||||
#include <coreinit/filesystem.h>
|
||||
#include <coreinit/mutex.h>
|
||||
|
||||
typedef struct dirMagic {
|
||||
uint32_t handle{};
|
||||
|
@ -1,18 +1,18 @@
|
||||
#include "FileUtils.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <mutex>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "utils/StringTools.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/utils.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <map>
|
||||
#include <coreinit/thread.h>
|
||||
#include <dirent.h>
|
||||
#include <coreinit/cache.h>
|
||||
#include "utils/StringTools.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/logger.h"
|
||||
#include <map>
|
||||
|
||||
extern "C" OSMessageQueue *OSGetDefaultAppIOQueue();
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <coreinit/filesystem.h>
|
||||
#include <romfs_dev.h>
|
||||
#include <string>
|
||||
|
||||
struct WUT_PACKED FSCmdBlockBody { //! FSAsyncResult object used for this command.
|
||||
|
||||
WUT_UNKNOWN_BYTES(0x96C);
|
||||
FSAsyncResult asyncResult;
|
||||
|
||||
};
|
||||
WUT_CHECK_OFFSET(FSCmdBlockBody, 0x96C, asyncResult);
|
||||
WUT_CHECK_SIZE(FSCmdBlockBody, 0x96C + 0x28);
|
||||
|
@ -1,21 +1,21 @@
|
||||
#include <string>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/ios.h>
|
||||
#include <romfs_dev.h>
|
||||
#include "utils/logger.h"
|
||||
#include "RPXLoading.h"
|
||||
#include "globals.h"
|
||||
#include "FileUtils.h"
|
||||
#include <nn/acp/title.h>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include "globals.h"
|
||||
#include "utils/FileReader.h"
|
||||
#include "utils/FileReaderCompressed.h"
|
||||
#include "utils/StringTools.h"
|
||||
#include "utils/ini.h"
|
||||
#include "utils/logger.h"
|
||||
#include <algorithm>
|
||||
#include <coreinit/cache.h>
|
||||
#include <coreinit/ios.h>
|
||||
#include <cstring>
|
||||
#include <rpxloader.h>
|
||||
#include <dirent.h>
|
||||
#include <memory>
|
||||
#include <nn/acp/title.h>
|
||||
#include <romfs_dev.h>
|
||||
#include <rpxloader.h>
|
||||
#include <string>
|
||||
|
||||
/*
|
||||
* Patch the meta xml for the home menu
|
||||
@ -57,7 +57,6 @@ DECL_FUNCTION(FSStatus, RPX_FSReadFile, FSClient *client, FSCmdBlock *block, uin
|
||||
if ((handle & 0xF0000000) == 0x80000000) {
|
||||
auto reader = (FileReader *) handle;
|
||||
return (FSStatus) reader->read(buffer, size * count);
|
||||
|
||||
}
|
||||
FSStatus result = real_RPX_FSReadFile(client, block, buffer, size, count, handle, unk1, flags);
|
||||
return result;
|
||||
@ -180,7 +179,7 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
||||
request.path[0] = '\0';
|
||||
strncat(request.path, bundle_path, sizeof(request.path) - 1);
|
||||
|
||||
DCFlushRange(&request, sizeof(LOAD_REQUEST));
|
||||
DCFlushRange(&request, sizeof(request));
|
||||
|
||||
int success = false;
|
||||
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <function_patcher/function_patching.h>
|
||||
#include <cstdint>
|
||||
#include <function_patcher/function_patching.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -21,5 +21,3 @@ extern uint32_t rpx_utils_function_replacements_size;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <coreinit/filesystem.h>
|
||||
#include "globals.h"
|
||||
#include <coreinit/filesystem.h>
|
||||
|
||||
RPXLoader_ReplacementInformation gReplacementInfo __attribute__((section(".data")));
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <wums.h>
|
||||
#include <coreinit/mutex.h>
|
||||
#include <coreinit/filesystem.h>
|
||||
#include <coreinit/mutex.h>
|
||||
#include <wums.h>
|
||||
|
||||
typedef struct MetaInformation_t {
|
||||
char shortname[64];
|
||||
|
25
src/main.cpp
25
src/main.cpp
@ -1,22 +1,22 @@
|
||||
#include <wums.h>
|
||||
#include <cstring>
|
||||
#include <malloc.h>
|
||||
#include <wums.h>
|
||||
|
||||
#include "FSDirReplacements.h"
|
||||
#include "FSFileReplacements.h"
|
||||
#include "FileUtils.h"
|
||||
#include "RPXLoading.h"
|
||||
#include "globals.h"
|
||||
#include "utils/StringTools.h"
|
||||
#include "utils/logger.h"
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/title.h>
|
||||
#include <sysapp/title.h>
|
||||
#include <string>
|
||||
#include "utils/logger.h"
|
||||
#include "utils/StringTools.h"
|
||||
#include "FSFileReplacements.h"
|
||||
#include "globals.h"
|
||||
#include "FileUtils.h"
|
||||
#include "FSDirReplacements.h"
|
||||
#include "RPXLoading.h"
|
||||
#include <sysapp/title.h>
|
||||
|
||||
#include <romfs_dev.h>
|
||||
#include <coreinit/cache.h>
|
||||
#include <nn/act.h>
|
||||
#include <romfs_dev.h>
|
||||
|
||||
WUMS_MODULE_EXPORT_NAME("homebrew_rpx_loader");
|
||||
WUMS_USE_WUT_DEVOPTAB();
|
||||
@ -100,12 +100,12 @@ WUMS_APPLICATION_STARTS() {
|
||||
uint32_t currentHash = StringTools::hash(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath);
|
||||
|
||||
nn::act::Initialize();
|
||||
nn::act::PersistentId slot = nn::act::GetPersistentId();
|
||||
nn::act::PersistentId persistentId = nn::act::GetPersistentId();
|
||||
nn::act::Finalize();
|
||||
|
||||
std::string basePath = StringTools::strfmt("/vol/external01/wiiu/apps/save/%08X", currentHash);
|
||||
std::string common = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/common", currentHash);
|
||||
std::string user = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/%08X", currentHash, 0x80000000 | slot);
|
||||
std::string user = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/%08X", currentHash, 0x80000000 | persistentId);
|
||||
|
||||
gReplacementInfo.contentReplacementInfo.savePath[0] = '\0';
|
||||
strncat(gReplacementInfo.contentReplacementInfo.savePath,
|
||||
@ -140,4 +140,3 @@ WUMS_APPLICATION_STARTS() {
|
||||
DCFlushRange(&gReplacementInfo, sizeof(gReplacementInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ int FileReader::read(uint8_t *buffer, uint32_t size) {
|
||||
if (toRead == 0) {
|
||||
return 0;
|
||||
}
|
||||
memcpy(buffer, input_buffer + input_pos, toRead);
|
||||
memcpy(buffer, &input_buffer[input_pos], toRead);
|
||||
input_pos += toRead;
|
||||
return toRead;
|
||||
} else if (isReadFromFile) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
class FileReader {
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <zlib.h>
|
||||
#include "FileReader.h"
|
||||
#include "logger.h"
|
||||
#include <zlib.h>
|
||||
|
||||
#define BUFFER_SIZE 0x20000
|
||||
|
||||
@ -12,8 +12,7 @@ public:
|
||||
|
||||
explicit FileReaderCompressed(std::string &file);
|
||||
|
||||
~FileReaderCompressed() override {
|
||||
}
|
||||
~FileReaderCompressed() override = default;
|
||||
|
||||
int read(uint8_t *buffer, uint32_t size) override;
|
||||
|
||||
|
@ -23,22 +23,22 @@
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <strings.h>
|
||||
#include <wut_types.h>
|
||||
#include <stdio.h>
|
||||
#include <utils/StringTools.h>
|
||||
#include <vector>
|
||||
#include <wchar.h>
|
||||
#include <wut_types.h>
|
||||
|
||||
|
||||
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
|
||||
if (b.size() > a.size())
|
||||
if (b.size() > a.size()) {
|
||||
return false;
|
||||
}
|
||||
return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin());
|
||||
}
|
||||
|
||||
@ -301,4 +301,3 @@ uint32_t StringTools::hash(char *str) {
|
||||
}
|
||||
return h; // or, h % ARRAY_SIZE;
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
#ifndef __STRING_TOOLS_H
|
||||
#define __STRING_TOOLS_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wut_types.h>
|
||||
|
||||
class StringTools {
|
||||
@ -64,4 +64,3 @@ public:
|
||||
};
|
||||
|
||||
#endif /* __STRING_TOOLS_H */
|
||||
|
||||
|
@ -1,12 +1,16 @@
|
||||
/* inih -- simple .INI file parser
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
Copyright (C) 2009-2020, Ben Hoyt
|
||||
|
||||
inih is released under the New BSD license (see LICENSE.txt). Go to the project
|
||||
home page for more info:
|
||||
|
||||
https://github.com/benhoyt/inih
|
||||
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
@ -18,9 +22,17 @@ https://github.com/benhoyt/inih
|
||||
#include "ini.h"
|
||||
|
||||
#if !INI_USE_STACK
|
||||
|
||||
#if INI_CUSTOM_ALLOCATOR
|
||||
#include <stddef.h>
|
||||
void* ini_malloc(size_t size);
|
||||
void ini_free(void* ptr);
|
||||
void* ini_realloc(void* ptr, size_t size);
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ini_malloc malloc
|
||||
#define ini_free free
|
||||
#define ini_realloc realloc
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MAX_SECTION 50
|
||||
@ -33,7 +45,8 @@ typedef struct {
|
||||
} ini_parse_string_ctx;
|
||||
|
||||
/* Strip whitespace chars off end of given string, in place. Return s. */
|
||||
static char *rstrip(char *s) {
|
||||
static char* rstrip(char* s)
|
||||
{
|
||||
char* p = s + strlen(s);
|
||||
while (p > s && isspace((unsigned char)(*--p)))
|
||||
*p = '\0';
|
||||
@ -41,16 +54,18 @@ static char *rstrip(char *s) {
|
||||
}
|
||||
|
||||
/* Return pointer to first non-whitespace char in given string. */
|
||||
static char *lskip(const char *s) {
|
||||
static char* lskip(const char* s)
|
||||
{
|
||||
while (*s && isspace((unsigned char)(*s)))
|
||||
s++;
|
||||
return (char*)s;
|
||||
}
|
||||
|
||||
/* Return pointer to first char (of chars) or inline comment in given string,
|
||||
or pointer to null at end of string if neither found. Inline comment must
|
||||
or pointer to NUL at end of string if neither found. Inline comment must
|
||||
be prefixed by a whitespace character to register as a comment. */
|
||||
static char *find_chars_or_comment(const char *s, const char *chars) {
|
||||
static char* find_chars_or_comment(const char* s, const char* chars)
|
||||
{
|
||||
#if INI_ALLOW_INLINE_COMMENTS
|
||||
int was_space = 0;
|
||||
while (*s && (!chars || !strchr(chars, *s)) &&
|
||||
@ -66,30 +81,33 @@ static char *find_chars_or_comment(const char *s, const char *chars) {
|
||||
return (char*)s;
|
||||
}
|
||||
|
||||
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
|
||||
static char *strncpy0(char *dest, const char *src, size_t size) {
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstringop-truncation"
|
||||
strncpy(dest, src, size - 1);
|
||||
#pragma GCC diagnostic pop
|
||||
dest[size - 1] = '\0';
|
||||
/* Similar to strncpy, but ensures dest (size bytes) is
|
||||
NUL-terminated, and doesn't pad with NULs. */
|
||||
static char* strncpy0(char* dest, const char* src, size_t size)
|
||||
{
|
||||
/* Could use strncpy internally, but it causes gcc warnings (see issue #91) */
|
||||
size_t i;
|
||||
for (i = 0; i < size - 1 && src[i]; i++)
|
||||
dest[i] = src[i];
|
||||
dest[i] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* See documentation in header file. */
|
||||
int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
||||
void *user) {
|
||||
void* user)
|
||||
{
|
||||
/* Uses a fair bit of stack (use heap instead if you need to) */
|
||||
#if INI_USE_STACK
|
||||
char line[INI_MAX_LINE];
|
||||
int max_line = INI_MAX_LINE;
|
||||
#else
|
||||
char* line;
|
||||
int max_line = INI_INITIAL_ALLOC;
|
||||
size_t max_line = INI_INITIAL_ALLOC;
|
||||
#endif
|
||||
#if INI_ALLOW_REALLOC
|
||||
#if INI_ALLOW_REALLOC && !INI_USE_STACK
|
||||
char* new_line;
|
||||
int offset;
|
||||
size_t offset;
|
||||
#endif
|
||||
char section[MAX_SECTION] = "";
|
||||
char prev_name[MAX_NAME] = "";
|
||||
@ -102,7 +120,7 @@ int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
|
||||
int error = 0;
|
||||
|
||||
#if !INI_USE_STACK
|
||||
line = (char *) malloc(INI_INITIAL_ALLOC);
|
||||
line = (char*)ini_malloc(INI_INITIAL_ALLOC);
|
||||
if (!line) {
|
||||
return -2;
|
||||
}
|
||||
@ -115,20 +133,20 @@ int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
|
||||
#endif
|
||||
|
||||
/* Scan through stream line by line */
|
||||
while (reader(line, max_line, stream) != NULL) {
|
||||
#if INI_ALLOW_REALLOC
|
||||
while (reader(line, (int)max_line, stream) != NULL) {
|
||||
#if INI_ALLOW_REALLOC && !INI_USE_STACK
|
||||
offset = strlen(line);
|
||||
while (offset == max_line - 1 && line[offset - 1] != '\n') {
|
||||
max_line *= 2;
|
||||
if (max_line > INI_MAX_LINE)
|
||||
max_line = INI_MAX_LINE;
|
||||
new_line = realloc(line, max_line);
|
||||
new_line = ini_realloc(line, max_line);
|
||||
if (!new_line) {
|
||||
free(line);
|
||||
ini_free(line);
|
||||
return -2;
|
||||
}
|
||||
line = new_line;
|
||||
if (reader(line + offset, max_line - offset, stream) == NULL)
|
||||
if (reader(line + offset, (int)(max_line - offset), stream) == NULL)
|
||||
break;
|
||||
if (max_line >= INI_MAX_LINE)
|
||||
break;
|
||||
@ -166,11 +184,17 @@ int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
|
||||
*end = '\0';
|
||||
strncpy0(section, start + 1, sizeof(section));
|
||||
*prev_name = '\0';
|
||||
} else if (!error) {
|
||||
#if INI_CALL_HANDLER_ON_NEW_SECTION
|
||||
if (!HANDLER(user, section, NULL, NULL) && !error)
|
||||
error = lineno;
|
||||
#endif
|
||||
}
|
||||
else if (!error) {
|
||||
/* No ']' found on section line */
|
||||
error = lineno;
|
||||
}
|
||||
} else if (*start) {
|
||||
}
|
||||
else if (*start) {
|
||||
/* Not a comment, must be a name[=:]value pair */
|
||||
end = find_chars_or_comment(start, "=:");
|
||||
if (*end == '=' || *end == ':') {
|
||||
@ -189,9 +213,17 @@ int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
|
||||
strncpy0(prev_name, name, sizeof(prev_name));
|
||||
if (!HANDLER(user, section, name, value) && !error)
|
||||
error = lineno;
|
||||
} else if (!error) {
|
||||
}
|
||||
else if (!error) {
|
||||
/* No '=' or ':' found on name[=:]value line */
|
||||
#if INI_ALLOW_NO_VALUE
|
||||
*end = '\0';
|
||||
name = rstrip(start);
|
||||
if (!HANDLER(user, section, name, NULL) && !error)
|
||||
error = lineno;
|
||||
#else
|
||||
error = lineno;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,19 +234,21 @@ int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
|
||||
}
|
||||
|
||||
#if !INI_USE_STACK
|
||||
free(line);
|
||||
ini_free(line);
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* See documentation in header file. */
|
||||
int ini_parse_file(FILE *file, ini_handler handler, void *user) {
|
||||
int ini_parse_file(FILE* file, ini_handler handler, void* user)
|
||||
{
|
||||
return ini_parse_stream((ini_reader)fgets, file, handler, user);
|
||||
}
|
||||
|
||||
/* See documentation in header file. */
|
||||
int ini_parse(const char *filename, ini_handler handler, void *user) {
|
||||
int ini_parse(const char* filename, ini_handler handler, void* user)
|
||||
{
|
||||
FILE* file;
|
||||
int error;
|
||||
|
||||
|
@ -1,14 +1,18 @@
|
||||
/* inih -- simple .INI file parser
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
Copyright (C) 2009-2020, Ben Hoyt
|
||||
|
||||
inih is released under the New BSD license (see LICENSE.txt). Go to the project
|
||||
home page for more info:
|
||||
|
||||
https://github.com/benhoyt/inih
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __INI_H__
|
||||
#define __INI_H__
|
||||
// clang-format off
|
||||
#ifndef INI_H
|
||||
#define INI_H
|
||||
|
||||
/* Make this header file easier to include in C++ code */
|
||||
#ifdef __cplusplus
|
||||
@ -73,7 +77,7 @@ int ini_parse_string(const char *string, ini_handler handler, void *user);
|
||||
#endif
|
||||
|
||||
/* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
|
||||
the file. See http://code.google.com/p/inih/issues/detail?id=21 */
|
||||
the file. See https://github.com/benhoyt/inih/issues/21 */
|
||||
#ifndef INI_ALLOW_BOM
|
||||
#define INI_ALLOW_BOM 1
|
||||
#endif
|
||||
@ -123,8 +127,31 @@ int ini_parse_string(const char *string, ini_handler handler, void *user);
|
||||
#define INI_STOP_ON_FIRST_ERROR 0
|
||||
#endif
|
||||
|
||||
/* Nonzero to call the handler at the start of each new section (with
|
||||
name and value NULL). Default is to only call the handler on
|
||||
each name=value pair. */
|
||||
#ifndef INI_CALL_HANDLER_ON_NEW_SECTION
|
||||
#define INI_CALL_HANDLER_ON_NEW_SECTION 0
|
||||
#endif
|
||||
|
||||
/* Nonzero to allow a name without a value (no '=' or ':' on the line) and
|
||||
call the handler with value NULL in this case. Default is to treat
|
||||
no-value lines as an error. */
|
||||
#ifndef INI_ALLOW_NO_VALUE
|
||||
#define INI_ALLOW_NO_VALUE 0
|
||||
#endif
|
||||
|
||||
/* Nonzero to use custom ini_malloc, ini_free, and ini_realloc memory
|
||||
allocation functions (INI_USE_STACK must also be 0). These functions must
|
||||
have the same signatures as malloc/free/realloc and behave in a similar
|
||||
way. ini_realloc is only needed if INI_ALLOW_REALLOC is set. */
|
||||
#ifndef INI_CUSTOM_ALLOCATOR
|
||||
#define INI_CUSTOM_ALLOCATOR 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INI_H__ */
|
||||
#endif /* INI_H */
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifdef DEBUG
|
||||
#include <stdint.h>
|
||||
#include <whb/log_udp.h>
|
||||
#include <whb/log_cafe.h>
|
||||
#include <whb/log_module.h>
|
||||
#include <whb/log_udp.h>
|
||||
|
||||
uint32_t moduleLogInit = false;
|
||||
uint32_t cafeLogInit = false;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <whb/log.h>
|
||||
#include <string.h>
|
||||
#include <whb/log.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -14,11 +14,13 @@ extern "C" {
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
|
||||
do { \
|
||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
|
||||
do { \
|
||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||
} while (0)
|
||||
|
||||
@ -39,4 +41,3 @@ void deinitLogging();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "utils/logger.h"
|
||||
#include <string.h>
|
||||
#include <whb/log.h>
|
||||
#include "utils/logger.h"
|
||||
|
||||
#define PRINTF_BUFFER_LENGTH 2048
|
||||
|
||||
|
@ -11,7 +11,8 @@ extern "C" {
|
||||
typeof(x) _x = x; \
|
||||
typeof(min) _min = min; \
|
||||
typeof(max) _max = max; \
|
||||
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \
|
||||
(((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
|
||||
: (_x)); \
|
||||
})
|
||||
|
||||
#define DegToRad(a) ((a) *0.01745329252f)
|
||||
|
Loading…
Reference in New Issue
Block a user