utils: Add helper functions for switching to flash* devices

This commit is contained in:
joel16 2024-01-05 10:41:59 -05:00
parent 39e1736ea6
commit 841940c8ed
2 changed files with 16 additions and 0 deletions

View File

@ -15,3 +15,4 @@ void utilsLogError(const char *error, ...);
int utilsGetEnterButton(void);
int utilsGetCancelButton(void);
void utilsGetSizeString(char *string, int size);
int utilsSetDevice(const char *dev, const char *dev2, const char *dev3, char *dst);

View File

@ -140,3 +140,18 @@ void utilsGetSizeString(char *string, int size) {
sprintf(string, "%.*f %s", (i == 0) ? 0 : 2, (double)size, units[i]);
}
int utilsSetDevice(const char *dev, const char *dev2, const char *dev3, char *dst) {
int ret = 0;
if ((R_FAILED(ret = sceIoUnassign(dev))) && (ret != 0x80020321)) {
utilsLogError("sceIoUnassign(%s) failed: 0x%x\n", dev, ret);
}
if (R_FAILED(ret = sceIoAssign(dev, dev2, dev3, IOASSIGN_RDWR, NULL, 0))) {
utilsLogError("sceIoAssign(%s) failed: 0x%x\n", dev, ret);
}
snprintf(dst, 10, "%s/", dev);
return ret;
}