diff --git a/app/include/utils.h b/app/include/utils.h index a45b17e..8d615d0 100644 --- a/app/include/utils.h +++ b/app/include/utils.h @@ -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); diff --git a/app/source/utils.c b/app/source/utils.c index 28b49bf..a26d804 100644 --- a/app/source/utils.c +++ b/app/source/utils.c @@ -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; +}