mirror of
https://github.com/rvtr/unlaunch-installer_dev.git
synced 2026-01-26 13:43:08 -05:00
Fix various errors from last commit
This commit is contained in:
parent
6d5cff81c3
commit
a6e2c31c14
@ -214,7 +214,7 @@ bool writeToFile(FILE* fd, const char* buffer, size_t size)
|
||||
toWrite -= written;
|
||||
buffer += written;
|
||||
}
|
||||
return toWrite != 0;
|
||||
return toWrite == 0;
|
||||
}
|
||||
|
||||
//directories
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "message.h"
|
||||
#include "storage.h"
|
||||
#include "unlaunch.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -137,6 +138,7 @@ static bool writeUnlaunchTmd(const char* path)
|
||||
if(!writeToFile(targetTmd, unlaunchInstallerBuffer, sizeof(unlaunchInstallerBuffer)))
|
||||
{
|
||||
fclose(targetTmd);
|
||||
remove(path);
|
||||
messageBox("\x1B[31mError:\x1B[33m Failed write unlaunch to tmd\n");
|
||||
return false;
|
||||
}
|
||||
@ -204,7 +206,6 @@ static bool installUnlaunchRetailConsole(const char* retailLauncherTmdPath)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
messageBox("Unlaunch has been installed.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -262,18 +263,25 @@ bool readUnlaunchInstaller(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
int toRead = sizeof(unlaunchInstallerBuffer) - 520;
|
||||
size_t installerFilesize = getFileSize(unlaunchInstaller);
|
||||
if(installerFilesize != toRead)
|
||||
{
|
||||
messageBox("\x1B[31mError:\x1B[33m Unlaunch installer wrong file size\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
char* buff = unlaunchInstallerBuffer;
|
||||
// Pad the installer with 520 bytes, those being the size of a valid tmd
|
||||
buff += 520;
|
||||
|
||||
int toRead = sizeof(unlaunchInstallerBuffer) - 520;
|
||||
size_t n = 0;
|
||||
while (toRead != 0 && (n = fread(buff, sizeof(char), toRead, unlaunchInstaller)) > 0)
|
||||
{
|
||||
toRead -= n;
|
||||
buff += n;
|
||||
}
|
||||
if (toRead != 0 || !feof(unlaunchInstaller) || ferror(unlaunchInstaller))
|
||||
if (toRead != 0 || ferror(unlaunchInstaller))
|
||||
{
|
||||
fclose(unlaunchInstaller);
|
||||
messageBox("\x1B[31mError:\x1B[33m Failed read unlaunch installer\n");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user