Skip to content

Commit

Permalink
Added group RW permissions on files and folders when moving
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOfficialFloW committed Oct 27, 2016
1 parent 4119bb0 commit faa94dc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
21 changes: 20 additions & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit faa94dc

Please sign in to comment.