Merge master into developer, remove createDirectory calls

This commit is contained in:
Aurora 2016-08-30 17:09:04 +02:00
commit ae8caf3d3a
7 changed files with 46 additions and 49 deletions

View File

@ -25,7 +25,7 @@ INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)/include)
ASFLAGS := -mcpu=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -std=c11 -O2 -flto -ffast-math -mword-relocations \
-ffunction-sections -fdata-sections $(INCLUDE) -DARM11 -D_3DS
LDFLAGS := -Xlinker --defsym="__start__=0x14000000" -specs=3dsx.specs $(ASFLAGS) -L$(DEVKITPRO)/libctru/lib
LDFLAGS := -Xlinker --defsym="__start__=0x14000000" -specs=3dsx.specs $(ASFLAGS)
objects = $(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.s *.c))

View File

@ -57,11 +57,7 @@ void writeConfig(const char *configPath, u32 configTemp)
configData.formatVersionMinor = CONFIG_VERSIONMINOR;
if(!fileWrite(&configData, configPath, sizeof(cfgData)))
{
createDirectory("luma");
if(!fileWrite(&configData, configPath, sizeof(cfgData)))
error("Error writing the configuration file");
}
error("Error writing the configuration file");
}
}

View File

@ -121,13 +121,7 @@ void detectAndProcessExceptionDumps(void)
path[fileNameSpot] = '/';
memcpy(&path[fileNameSpot + 1], fileName, sizeof(fileName));
if(!fileWrite((void *)dumpHeader, path, size))
{
createDirectory("/luma");
createDirectory("/luma/dumps");
createDirectory(pathFolder);
fileWrite((void *)dumpHeader, path, size);
}
fileWrite((void *)dumpHeader, path, size);
vu32 *regs = (vu32 *)((vu8 *)dumpHeader + sizeof(ExceptionDumpHeader));
vu8 *additionalData = (vu8 *)dumpHeader + dumpHeader->totalSize - dumpHeader->additionalDataSize;

View File

@ -64,7 +64,9 @@ bool fileWrite(const void *buffer, const char *path, u32 size)
{
FIL file;
if(f_open(&file, path, FA_WRITE | FA_OPEN_ALWAYS) == FR_OK)
FRESULT result = f_open(&file, path, FA_WRITE | FA_OPEN_ALWAYS);
if(result == FR_OK)
{
unsigned int written;
f_write(&file, buffer, size, &written);
@ -72,8 +74,21 @@ bool fileWrite(const void *buffer, const char *path, u32 size)
return true;
}
else if(result == FR_NO_PATH)
{
char folder[256];
return false;
for(u32 i = 1; path[i] != 0; i++)
if(path[i] == '/')
{
memcpy(folder, path, i);
folder[i] = 0;
f_mkdir(folder);
}
return fileWrite(buffer, path, size);
}
else return false;
}
void fileDelete(const char *path)
@ -81,11 +96,6 @@ void fileDelete(const char *path)
f_unlink(path);
}
void createDirectory(const char *path)
{
f_mkdir(path);
}
void loadPayload(u32 pressed)
{
const char *pattern;
@ -132,27 +142,6 @@ void loadPayload(u32 pressed)
}
}
void findDumpFile(const char *path, char *fileName)
{
DIR dir;
FILINFO info;
u32 n = 0;
while(f_findfirst(&dir, &info, path, fileName) == FR_OK && info.fname[0])
{
u32 i = 18,
tmp = ++n;
while(tmp)
{
fileName[i--] = '0' + (tmp % 10);
tmp /= 10;
}
}
f_closedir(&dir);
}
u32 firmRead(void *dest, u32 firmType)
{
const char *firmFolders[4][2] = {{ "00000002", "20000002" },
@ -209,3 +198,24 @@ u32 firmRead(void *dest, u32 firmType)
return firmVersion;
}
void findDumpFile(const char *path, char *fileName)
{
DIR dir;
FILINFO info;
u32 n = 0;
while(f_findfirst(&dir, &info, path, fileName) == FR_OK && info.fname[0])
{
u32 i = 18,
tmp = ++n;
while(tmp)
{
fileName[i--] = '0' + (tmp % 10);
tmp /= 10;
}
}
f_closedir(&dir);
}

View File

@ -33,6 +33,7 @@ u32 fileRead(void *dest, const char *path);
u32 getFileSize(const char *path);
bool fileWrite(const void *buffer, const char *path, u32 size);
void fileDelete(const char *path);
void createDirectory(const char *path);
void loadPayload(u32 pressed);
u32 firmRead(void *dest, u32 firmType);
void findDumpFile(const char *path, char *fileName);
void loadPayload(u32 pressed);u32 firmRead(void *dest, u32 firmType);

View File

@ -41,7 +41,7 @@ void memset32(void *dest, u32 filler, u32 size)
{
u32 *dest32 = (u32 *)dest;
for (u32 i = 0; i < size / 4; i++)
for(u32 i = 0; i < size / 4; i++)
dest32[i] = filler;
}

View File

@ -96,11 +96,7 @@ void newPin(bool allowSkipping)
memcpy(pin.hash, tmp, 32);
if(!fileWrite(&pin, "/luma/pin.bin", sizeof(PINData)))
{
createDirectory("luma");
if(!fileWrite(&pin, "/luma/pin.bin", sizeof(PINData)))
error("Error writing the PIN file");
}
error("Error writing the PIN file");
}
bool verifyPin(void)