Skip to content

Commit

Permalink
Format the code via clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed Jul 26, 2022
1 parent 8d0f382 commit 990c67d
Show file tree
Hide file tree
Showing 109 changed files with 626 additions and 591 deletions.
67 changes: 67 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +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: Checkout submodules using a PAT
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./source
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: Checkout submodules using a PAT
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ It's possible to use a docker image for building. This way you don't need anythi

```
# Build docker image (only needed once)
docker build . -t WUDD-builder
docker build . -t wudd-builder
# make
docker run -it --rm -v ${PWD}:/project WUDD-builder make
docker run -it --rm -v ${PWD}:/project wudd-builder make
# make clean
docker run -it --rm -v ${PWD}:/project WUDD-builder make clean
```
docker run -it --rm -v ${PWD}:/project wudd-builder make clean
```

## Format the code via docker

`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source -i`
7 changes: 4 additions & 3 deletions source/ApplicationState.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once


#include <utils/WiiUScreen.h>
#include <utils/ScreenUtils.h>
#include "input/Input.h"
#include "utils/ScreenUtils.h"
#include "utils/WiiUScreen.h"
#include <stdint.h>

class ApplicationState {
public:
Expand Down
38 changes: 18 additions & 20 deletions source/GMPartitionsDumperState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <common/common.h>
#include <iosuhax.h>
#include <memory>
#include "GMPartitionsDumperState.h"
#include <WUD/DiscReaderDiscDrive.h>
#include <WUD/NUSTitle.h>
#include <WUD/content/partitions/WiiUGMPartition.h>
#include <WUD/header/WiiUDiscHeader.h>
#include <common/common.h>
#include <fs/FSUtils.h>
#include <WUD/content/partitions/WiiUGMPartition.h>
#include <WUD/NUSTitle.h>
#include "GMPartitionsDumperState.h"
#include <iosuhax.h>
#include <memory>
#include <utils/StringTools.h>

#define READ_BUFFER_SIZE (SECTOR_SIZE * 128)

GMPartitionsDumperState::GMPartitionsDumperState(eDumpTarget pTargetDevice) : targetDevice(pTargetDevice) {
this->sectorBufSize = SECTOR_SIZE;
this->state = STATE_OPEN_ODD1;
this->state = STATE_OPEN_ODD1;
}

GMPartitionsDumperState::~GMPartitionsDumperState() {
Expand Down Expand Up @@ -72,9 +72,9 @@ void GMPartitionsDumperState::render() {
WiiUScreen::drawLine("This disc has no dumpable GM partitions ");
} else {
uint32_t index = 0;
for (auto &partitionPair: gmPartitionPairs) {
for (auto &partitionPair : gmPartitionPairs) {
uint32_t size = 0;
for (auto &content: partitionPair.second->tmd->contentList) {
for (auto &content : partitionPair.second->tmd->contentList) {
size += ROUNDUP(content->encryptedFileSize, 16);
}
WiiUScreen::drawLinef("%s %s (~%0.2f MiB)", index == (uint32_t) selectedOptionY ? ">" : " ", partitionPair.first->getVolumeId().c_str(), (float) size / 1024.0f / 1024.0f);
Expand All @@ -98,10 +98,10 @@ void GMPartitionsDumperState::render() {
WiiUScreen::drawLine("Dumping Partition");
}

uint64_t partitionSize = 0;
uint64_t partitionSize = 0;
uint64_t partitionOffset = curOffsetInContent;
if (curNUSTitle != nullptr) {
for (auto &content: curNUSTitle->tmd->contentList) {
for (auto &content : curNUSTitle->tmd->contentList) {
partitionSize += ROUNDUP(content->encryptedFileSize, 16);
if (content->index < curContentIndex) {
partitionOffset += ROUNDUP(content->encryptedFileSize, 16);
Expand All @@ -122,7 +122,7 @@ void GMPartitionsDumperState::render() {
}

auto offset = curOffsetInContent;
auto size = curContent != nullptr ? ROUNDUP(curContent->encryptedFileSize, 16) : 0;
auto size = curContent != nullptr ? ROUNDUP(curContent->encryptedFileSize, 16) : 0;

if (size > 0) {
WiiUScreen::drawLinef("Progress: %.2f MiB / %.2f MiB (%0.2f%%)", offset / 1024.0f / 1024.0f,
Expand Down Expand Up @@ -205,10 +205,10 @@ ApplicationState::eSubState GMPartitionsDumperState::update(Input *input) {
return SUBSTATE_RUNNING;
}
this->discHeader = std::move(discHeaderOpt.value());
this->state = STATE_PROCESS_GM_PARTITIONS;
this->state = STATE_PROCESS_GM_PARTITIONS;
} else if (this->state == STATE_PROCESS_GM_PARTITIONS) {
this->gmPartitionPairs.clear();
for (auto &partition: discHeader->wiiUContentsInformation->partitions->partitions) {
for (auto &partition : discHeader->wiiUContentsInformation->partitions->partitions) {
auto gmPartition = std::dynamic_pointer_cast<WiiUGMPartition>(partition);
if (gmPartition != nullptr) {
auto nusTitleOpt = NUSTitle::loadTitleFromGMPartition(gmPartition, discReader, cKey);
Expand All @@ -235,7 +235,7 @@ ApplicationState::eSubState GMPartitionsDumperState::update(Input *input) {
auto gmPartitionPair = gmPartitionPairs[selectedOptionY];
if (gmPartitionPair.first != nullptr) {
this->curPartition = gmPartitionPair.first;
this->curNUSTitle = gmPartitionPair.second;
this->curNUSTitle = gmPartitionPair.second;
this->dataProvider = this->curNUSTitle->dataProcessor->getDataProvider();
} else {
DEBUG_FUNCTION_LINE("Failed to find a GM partition");
Expand Down Expand Up @@ -290,7 +290,7 @@ ApplicationState::eSubState GMPartitionsDumperState::update(Input *input) {
return SUBSTATE_RUNNING;
}
this->curContentIndex = 0;
this->state = STATE_DUMP_PARTITION_CONTENTS;
this->state = STATE_DUMP_PARTITION_CONTENTS;
} else if (this->state == STATE_DUMP_PARTITION_CONTENTS) {
// Get current content by index.
if (curContent == nullptr) {
Expand Down Expand Up @@ -386,13 +386,13 @@ ApplicationState::eSubState GMPartitionsDumperState::update(Input *input) {
}

void GMPartitionsDumperState::setError(GMPartitionsDumperState::eErrorState err) {
this->state = STATE_ERROR;
this->state = STATE_ERROR;
this->errorState = err;
//OSEnableHomeButtonMenu(true);
}

std::string GMPartitionsDumperState::getPathForDevice(eDumpTarget target) const {
if (target == TARGET_NTFS){
if (target == TARGET_NTFS) {
return "ntfs0:/";
}
return "fs:/vol/external01/";
Expand Down Expand Up @@ -504,5 +504,3 @@ std::string GMPartitionsDumperState::ErrorDescription() const {
}
return "UNKNOWN_ERROR";
}


27 changes: 14 additions & 13 deletions source/GMPartitionsDumperState.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
****************************************************************************/
#pragma once

#include <map>
#include <string>
#include <vector>
#include <memory>
#include <input/Input.h>
#include "ApplicationState.h"
#include "fs/WriteOnlyFileWithCache.h"
#include "common/common.h"
#include "fs/WUXFileWriter.h"
#include <WUD/entities/TMD/Content.h>
#include "fs/WriteOnlyFileWithCache.h"
#include <WUD/NUSTitle.h>
#include <WUD/entities/TMD/Content.h>
#include <WUD/header/WiiUDiscHeader.h>
#include <input/Input.h>
#include <map>
#include <memory>
#include <string>
#include <vector>

class GMPartitionsDumperState : public ApplicationState {
public:
Expand Down Expand Up @@ -88,22 +89,22 @@ class GMPartitionsDumperState : public ApplicationState {
std::array<uint8_t, 11> discId{};
std::array<uint8_t, 0x10> cKey{};

int32_t oddFd = -1;
int32_t oddFd = -1;
void *sectorBuf = nullptr;
uint32_t sectorBufSize;
std::shared_ptr<DiscReaderDiscDrive> discReader = nullptr;
std::unique_ptr<WiiUDiscHeader> discHeader = nullptr;
std::unique_ptr<WiiUDiscHeader> discHeader = nullptr;

std::shared_ptr<WiiUGMPartition> curPartition = nullptr;
std::shared_ptr<NUSDataProvider> dataProvider = nullptr;
std::string targetPath;
std::shared_ptr<NUSTitle> curNUSTitle = nullptr;

uint16_t curContentIndex = 0;
std::unique_ptr<CFile> contentFile = nullptr;
uint16_t curContentIndex = 0;
std::unique_ptr<CFile> contentFile = nullptr;
std::shared_ptr<Content> curContent = nullptr;
uint8_t *readBuffer = nullptr;
uint32_t curOffsetInContent = 0;
uint8_t *readBuffer = nullptr;
uint32_t curOffsetInContent = 0;

[[nodiscard]] std::string ErrorMessage() const;

Expand Down
11 changes: 6 additions & 5 deletions source/MainApplicationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "MainApplicationState.h"
#include "WUDDumperState.h"
#include "GMPartitionsDumperState.h"
#include "WUDDumperState.h"
#include <sysapp/launch.h>

MainApplicationState::MainApplicationState() {
DEBUG_FUNCTION_LINE("Welcome!");
this->state = STATE_WELCOME_SCREEN;
}

MainApplicationState::~MainApplicationState() = default;;
MainApplicationState::~MainApplicationState() = default;
;

void MainApplicationState::render() {
if (this->state == STATE_DO_SUBSTATE) {
Expand Down Expand Up @@ -73,13 +74,13 @@ ApplicationState::eSubState MainApplicationState::update(Input *input) {
}
if (entrySelected(input)) {
if (this->selectedOptionY == 0) {
this->state = STATE_DO_SUBSTATE;
this->state = STATE_DO_SUBSTATE;
this->subState = std::make_unique<WUDDumperState>(WUDDumperState::DUMP_AS_WUX, dumpTarget);
} else if (this->selectedOptionY == 1) {
this->state = STATE_DO_SUBSTATE;
this->state = STATE_DO_SUBSTATE;
this->subState = std::make_unique<WUDDumperState>(WUDDumperState::DUMP_AS_WUD, dumpTarget);
} else if (this->selectedOptionY == 2) {
this->state = STATE_DO_SUBSTATE;
this->state = STATE_DO_SUBSTATE;
this->subState = std::make_unique<GMPartitionsDumperState>(dumpTarget);
} else if (this->selectedOptionY == 3) {
//
Expand Down
12 changes: 6 additions & 6 deletions source/MainApplicationState.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
****************************************************************************/
#pragma once

#include "ApplicationState.h"
#include "fs/CFile.hpp"
#include "input/Input.h"
#include <common/common.h>
#include <ctime>
#include <map>
#include <memory>
#include <string>
#include <optional>
#include <queue>
#include <ctime>
#include <common/common.h>
#include "input/Input.h"
#include "fs/CFile.hpp"
#include "ApplicationState.h"
#include <string>


class MainApplicationState : public ApplicationState {
Expand Down
5 changes: 2 additions & 3 deletions source/WUD/DefaultNUSDataProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ std::shared_ptr<NUSDataProvider> DefaultNUSDataProcessor::getDataProvider() {

DefaultNUSDataProcessor::DefaultNUSDataProcessor(
std::shared_ptr<NUSDataProvider> pDataProvider,
std::shared_ptr<NUSDecryption> pNUSDecryption) :
dataProvider(std::move(pDataProvider)),
nusDecryption(std::move(pNUSDecryption)) {
std::shared_ptr<NUSDecryption> pNUSDecryption) : dataProvider(std::move(pDataProvider)),
nusDecryption(std::move(pNUSDecryption)) {
}
2 changes: 1 addition & 1 deletion source/WUD/DefaultNUSDataProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
****************************************************************************/
#pragma once

#include <utils/utils.h>
#include "NUSDataProcessor.h"
#include <utils/utils.h>

class DefaultNUSDataProcessor : public NUSDataProcessor {
public:
Expand Down
Loading

0 comments on commit 990c67d

Please sign in to comment.