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

@ -56,14 +56,10 @@ void writeConfig(const char *configPath, u32 configTemp)
configData.formatVersionMajor = CONFIG_VERSIONMAJOR;
configData.formatVersionMinor = CONFIG_VERSIONMINOR;
if(!fileWrite(&configData, configPath, sizeof(cfgData)))
{
createDirectory("luma");
if(!fileWrite(&configData, configPath, sizeof(cfgData)))
error("Error writing the configuration file");
}
}
}
void configMenu(bool oldPinStatus)
{

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);
}
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

@ -95,13 +95,9 @@ void newPin(bool allowSkipping)
computePinHash(tmp, enteredPassword, (PIN_LENGTH + 15) / 16);
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");
}
}
bool verifyPin(void)
{