From 30038aa526bb7579bdee5c4fe2fdb64a9882f61b Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 20 Jul 2022 18:55:26 +0200 Subject: [PATCH] Format the code via clang-format --- .clang-format | 67 ++++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 8 +++++ .github/workflows/pr.yml | 10 +++++- README.md | 6 ++++ source/main.cpp | 53 +++++++++++++++---------------- 5 files changed, 117 insertions(+), 27 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..56cc685 --- /dev/null +++ b/.clang-format @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d524b74..d728d15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 ./source build-binary: runs-on: ubuntu-18.04 + needs: clang-format steps: - uses: actions/checkout@v2 - name: build binary diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f907f7e..376a145 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,10 +3,18 @@ name: CI-PR on: [pull_request] jobs: - build-binary: + 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 ./source + build-binary: + runs-on: ubuntu-18.04 + needs: clang-format + steps: + - uses: actions/checkout@v2 - name: build binary run: | docker build . -t builder diff --git a/README.md b/README.md index 9e7566e..facd4dc 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![CI-Release](https://github.com/wiiu-env/LaunchInstaller/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/LaunchInstaller/actions/workflows/ci.yml) + # LaunchInstaller ## Usage @@ -24,5 +26,9 @@ docker run -it --rm -v ${PWD}:/project launchinstaller-builder make docker run -it --rm -v ${PWD}:/project launchinstaller-builder make clean ``` +## Format the code via docker + +`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source -i` + ## Credits Maschell \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 01efc3a..3d0ab9b 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,13 +1,13 @@ -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -40,12 +40,12 @@ int32_t getRPXInfoForPath(const std::string &path, romfs_fileInfo *info) { return -2; } bool found = false; - int res = -3; + int res = -3; while ((entry = readdir(dir)) != nullptr) { if (StringEndsWith(entry->d_name, ".rpx")) { if (romfsGetFileInfoPerPath("rcc", (std::string("code/") + entry->d_name).c_str(), info) >= 0) { found = true; - res = 0; + res = 0; } break; } @@ -61,33 +61,34 @@ int32_t getRPXInfoForPath(const std::string &path, romfs_fileInfo *info) { return res; } -int main(int argc, char **argv) { - std::string bundle_path = "wiiu/apps/PayloadLoaderInstaller.wuhb"; +int main(int argc, char **argv) { + std::string bundle_path = "wiiu/apps/PayloadLoaderInstaller.wuhb"; std::string completePath = std::string("/vol/external01/") + bundle_path; - + if (fopen(completePath.c_str(), "r") == NULL) { - OSFatal("\"sd:/wiiu/apps/PayloadLoaderInstaller.wuhb\" is missing on the sd card");; + OSFatal("\"sd:/wiiu/apps/PayloadLoaderInstaller.wuhb\" is missing on the sd card"); + ; } - + LOAD_REQUEST request; memset(&request, 0, sizeof(request)); - request.command = 0xFC; // IPC_CUSTOM_LOAD_CUSTOM_RPX; - request.target = 0; // LOAD_FILE_TARGET_SD_CARD - request.filesize = 0; // unknown filesize - request.fileoffset = 0; // - request.path[0] = '\0'; - + request.command = 0xFC; // IPC_CUSTOM_LOAD_CUSTOM_RPX; + request.target = 0; // LOAD_FILE_TARGET_SD_CARD + request.filesize = 0; // unknown filesize + request.fileoffset = 0; // + request.path[0] = '\0'; + romfs_fileInfo info; int res = getRPXInfoForPath(completePath, &info); - + if (res >= 0) { - request.filesize = ((uint32_t *) &info.length)[1]; + request.filesize = ((uint32_t *) &info.length)[1]; request.fileoffset = ((uint32_t *) &info.offset)[1]; } - strncat(request.path, bundle_path.c_str() , sizeof(request.path) - 1); + strncat(request.path, bundle_path.c_str(), sizeof(request.path) - 1); DCFlushRange(&request, sizeof(LOAD_REQUEST)); int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0); @@ -98,11 +99,11 @@ int main(int argc, char **argv) { } uint64_t titleID = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY); - if( OSGetTitleID() == titleID){ + if (OSGetTitleID() == titleID) { OSRestartGame(); } else { _SYSLaunchTitleWithStdArgsInNoSplash(titleID, 0); } - + return 0; }