Added group RW permissions on files and folders when moving

This commit is contained in:
TheFloW 2016-10-27 19:48:05 +02:00
parent 4119bb01ac
commit faa94dcaf2
2 changed files with 23 additions and 1 deletions

View File

@ -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.

21
file.c
View File

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