VirtualBox

Changeset 31309 in vbox


Ignore:
Timestamp:
Aug 2, 2010 2:58:35 PM (14 years ago)
Author:
vboxsync
Message:

IPRT/posix: Added RTPathSetMode().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/path-posix.cpp

    r31302 r31309  
    644644    LogFlow(("RTPathSetOwnerEx(%p:{%s}, uid, gid): return %Rrc\n",
    645645             pszPath, pszPath, uid, gid, rc));
     646    return rc;
     647}
     648
     649
     650RTR3DECL(int) RTPathSetMode(const char *pszPath, RTFMODE fMode)
     651{
     652    AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
     653    AssertReturn(*pszPath, VERR_INVALID_PARAMETER);
     654
     655    int rc;
     656    fMode = rtFsModeNormalize(fMode, pszPath, 0);
     657    if (rtFsModeIsValidPermissions(fMode))
     658    {
     659        char const *pszNativePath;
     660        rc = rtPathToNative(&pszNativePath, pszPath, NULL);
     661        if (RT_SUCCESS(rc))
     662        {
     663            char szRealPath[RTPATH_MAX];
     664            rc = RTPathReal(pszPath, szRealPath, sizeof(szRealPath));
     665            if (RT_SUCCESS(rc))
     666            {
     667                if (chmod(szRealPath, fMode & RTFS_UNIX_MASK) < 0)
     668                    rc = RTErrConvertFromErrno(errno);
     669            }
     670            rtPathFreeNative(pszNativePath, pszPath);
     671        }
     672    }
     673    else
     674    {
     675        AssertMsgFailed(("Invalid file mode! %RTfmode\n", fMode));
     676        rc = VERR_INVALID_FMODE;
     677    }
    646678    return rc;
    647679}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette