diff --git a/README.md b/README.md index c8201d9b..517de174 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,9 @@ Be sure you pull request your customized design or language file there. * Everybody who contributed on vitasdk ### Changelog X.XX ### +- Added group RW permissions on files and folders when moving. + Safe homebrews like RetroArch will now recognize files and folders + that you have moved from 'ux0:video'. - Added possibility to choose compression level. - Fixed time information in zip archives. diff --git a/file.c b/file.c index dba484c0..bec817b5 100644 --- a/file.c +++ b/file.c @@ -94,6 +94,18 @@ int getFileSize(char *pInputFileName) return fileSize; } +int changePathPermissions(char *path, int perms) { + SceIoStat stat; + memset(&stat, 0, sizeof(SceIoStat)); + int res = sceIoGetstat(path, &stat); + if (res < 0) + return res; + + stat.st_mode |= perms; + + return sceIoChstat(path, &stat, 1); +} + int getFileSha1(char *pInputFileName, uint8_t *pSha1Out, FileProcessParam *param) { // Set up SHA1 context SHA1_CTX ctx; @@ -497,7 +509,11 @@ int movePath(char *src_path, char *dst_path, int flags, FileProcessParam *param) } int res = sceIoRename(src_path, dst_path); - if (res == SCE_ERROR_ERRNO_EEXIST && flags & (MOVE_INTEGRATE | MOVE_REPLACE)) { + + if (res >= 0) { + // Give group RW permissions + changePathPermissions(dst_path, SCE_S_IROTH | SCE_S_IWOTH); + } else if (res == SCE_ERROR_ERRNO_EEXIST && flags & (MOVE_INTEGRATE | MOVE_REPLACE)) { // Src stat SceIoStat src_stat; memset(&src_stat, 0, sizeof(SceIoStat)); @@ -528,6 +544,9 @@ int movePath(char *src_path, char *dst_path, int flags, FileProcessParam *param) if (res < 0) return res; + // Give group RW permissions + changePathPermissions(dst_path, SCE_S_IROTH | SCE_S_IWOTH); + return 1; }