Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ CFLAGS := -g -Wall -O3 -ffunction-sections \

CFLAGS += $(INCLUDE) -D__SWITCH__ -DVERSION='"$(APP_VERSION)"' `freetype-config --libs`

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions `freetype-config --cflags`
CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions `freetype-config --cflags`

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
Expand Down
3 changes: 3 additions & 0 deletions include/utils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <vector>
#include <nlohmann/json.hpp>

struct AmiiboEntry
{
Expand All @@ -21,6 +22,8 @@ struct AmiiboCreatorData
};

bool checkIfFileExists(char* path);
bool read_DB(nlohmann::json& base,std::string path);
bool write_DB(nlohmann::json base,std::string path);
std::vector<AmiiboEntry> scanForAmiibo(const char* path);
std::vector<std::string> getListOfSeries();
std::vector<AmiiboCreatorData> getAmiibosFromSeries(std::string series);
Expand Down
46 changes: 46 additions & 0 deletions source/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,58 @@
#include <emuiibo.hpp>
#include <AmiigoSettings.h>
#include <AmiigoUI.h>
#include <iostream>

bool checkIfFileExists(char* path)
{
return !access(path, F_OK);
}

bool read_DB(nlohmann::json& base,std::string path){
std::ifstream inf(path);
if(!inf.fail()) {
std::string tempjson="";
for(int f = 0; !inf.eof(); f++)
{
std::string TempLine = "";
getline(inf, TempLine);
tempjson += TempLine;
}
inf.close();
if(nlohmann::json::accept(tempjson))
{
//Parse and use the JSON data
base = nlohmann::json::parse(tempjson);
std::cout << "Json Readed... "<< path << std::endl;
return true;
}
}
return false;
}

bool write_DB(nlohmann::json base,std::string path){
std::string pathtemp = path+".tmp";
std::stringstream strm;
try{
strm << std::setw(4) << base;
// strm << base;
std::string A = strm.str();

std::ofstream otf(pathtemp);
otf << A;
otf.close();
remove(path.c_str());
rename(pathtemp.c_str(),path.c_str());

} catch(...) {
std::cout << "Json: write Error... "<< path << std::endl;
return false;
}
std::cout << "Json: writhen... "<< path << std::endl;
return true;
}


std::vector<AmiiboEntry> scanForAmiibo(const char* path)
{
//Open path
Expand Down