VirtualBox

Changeset 23291 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Sep 24, 2009 4:08:19 PM (15 years ago)
Author:
vboxsync
Message:

IPRT: RTPathQueryInfo and RTPathSetTimes should work on symbolic links when specified. Introduced Ex versions of these to work around this issue. Should also address the lack of symlinks in the RTDirReadEx output as well VWRN_NO_DIRENT_INFO on broken links.

Location:
trunk/include/iprt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/err.h

    r22722 r23291  
    710710/** Too many symbolic links. */
    711711#define VERR_TOO_MANY_SYMLINKS              (-156)
     712/** The OS does not support setting the time stamps on a symbolic link. */
     713#define VERR_NS_SYMLINK_SET_TIME            (-157)
    712714/** @} */
    713715
  • trunk/include/iprt/path.h

    r22109 r23291  
    118118
    119119
     120/** @name Generic RTPath flags
     121 * @{ */
     122/** Last component: Work on the link. */
     123#define RTPATH_F_ON_LINK          RT_BIT_32(0)
     124/** Last component: Follow if link. */
     125#define RTPATH_F_FOLLOW_LINK      RT_BIT_32(1)
     126/** @} */
     127
     128
     129/** Validates a flags parameter containing RTPATH_F_*.
     130 * @remarks The parameters will be referneced multiple times. */
     131#define RTPATH_F_IS_VALID(fFlags, fIgnore) \
     132    (    ((fFlags) & ~(uint32_t)(fIgnore)) == RTPATH_F_ON_LINK \
     133      || ((fFlags) & ~(uint32_t)(fIgnore)) == RTPATH_F_FOLLOW_LINK )
     134
     135
    120136/**
    121137 * Checks if the path exists.
    122138 *
    123  * Symbolic links will all be attempted resolved.
     139 * Symbolic links will all be attempted resolved and broken links means false.
    124140 *
    125141 * @returns true if it exists and false if it doesn't.
     
    127143 */
    128144RTDECL(bool) RTPathExists(const char *pszPath);
     145
     146/**
     147 * Checks if the path exists.
     148 *
     149 * @returns true if it exists and false if it doesn't.
     150 * @param   pszPath     The path to check.
     151 * @param   fFlags      RTPATH_F_ON_LINK or RPATH_F_FOLLOW_LINK.
     152 */
     153RTDECL(bool) RTPathExistsEx(const char *pszPath, uint32_t fFlags);
    129154
    130155/**
     
    500525 * Query information about a file system object.
    501526 *
    502  * This API will not resolve symbolic links in the last component (just
    503  * like unix lstat()).
    504  *
    505  * @returns VINF_SUCCESS if the object exists, information returned.
    506  * @returns VERR_PATH_NOT_FOUND if any but the last component in the specified
     527 * This API will resolve NOT symbolic links in the last component (just like
     528 * unix lstat()).
     529 *
     530 * @returns IPRT status code.
     531 * @retval  VINF_SUCCESS if the object exists, information returned.
     532 * @retval  VERR_PATH_NOT_FOUND if any but the last component in the specified
    507533 *          path was not found or was not a directory.
    508  * @returns VERR_FILE_NOT_FOUND if the object does not exist (but path to the
     534 * @retval VERR_FILE_NOT_FOUND if the object does not exist (but path to the
    509535 *          parent directory exists).
    510  * @returns some other iprt status code.
    511536 *
    512537 * @param   pszPath     Path to the file system object.
     
    519544
    520545/**
     546 * Query information about a file system object.
     547 *
     548 * @returns IPRT status code.
     549 * @retval  VINF_SUCCESS if the object exists, information returned.
     550 * @retval  VERR_PATH_NOT_FOUND if any but the last component in the specified
     551 *          path was not found or was not a directory.
     552 * @retval  VERR_FILE_NOT_FOUND if the object does not exist (but path to the
     553 *          parent directory exists).
     554 *
     555 * @param   pszPath     Path to the file system object.
     556 * @param   pObjInfo    Object information structure to be filled on successful return.
     557 * @param   enmAdditionalAttribs
     558 *                      Which set of additional attributes to request.
     559 *                      Use RTFSOBJATTRADD_NOTHING if this doesn't matter.
     560 * @param   fFlags      RTPATH_F_ON_LINK or RPATH_F_FOLLOW_LINK.
     561 */
     562RTR3DECL(int) RTPathQueryInfoEx(const char *pszPath, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags);
     563
     564/**
    521565 * Changes the mode flags of a file system object.
    522566 *
     
    573617
    574618/**
     619 * Changes one or more of the timestamps associated of file system object.
     620 *
     621 * @returns iprt status code.
     622 * @param   pszPath             Path to the file system object.
     623 * @param   pAccessTime         Pointer to the new access time.
     624 * @param   pModificationTime   Pointer to the new modification time.
     625 * @param   pChangeTime         Pointer to the new change time. NULL if not to be changed.
     626 * @param   pBirthTime          Pointer to the new time of birth. NULL if not to be changed.
     627 * @param   fFlags              RTPATH_F_ON_LINK or RPATH_F_FOLLOW_LINK.
     628 *
     629 * @remark  The file system might not implement all these time attributes,
     630 *          the API will ignore the ones which aren't supported.
     631 *
     632 * @remark  The file system might not implement the time resolution
     633 *          employed by this interface, the time will be chopped to fit.
     634 *
     635 * @remark  The file system may update the change time even if it's
     636 *          not specified.
     637 *
     638 * @remark  POSIX can only set Access & Modification and will always set both.
     639 */
     640RTR3DECL(int) RTPathSetTimesEx(const char *pszPath, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
     641                               PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime, uint32_t fFlags);
     642
     643/**
    575644 * Gets one or more of the timestamps associated of file system object.
    576645 *
     
    582651 * @param   pBirthTime          Where to store the creation time. NULL is ok.
    583652 *
    584  * @remark  This is wrapper around RTPathQueryInfo() and exists to complement RTPathSetTimes().
     653 * @remark  This is wrapper around RTPathQueryInfo() and exists to complement
     654 *          RTPathSetTimes().  If the last component is a symbolic link, it will
     655 *          not be resolved.
    585656 */
    586657RTR3DECL(int) RTPathGetTimes(const char *pszPath, PRTTIMESPEC pAccessTime, PRTTIMESPEC pModificationTime,
     
    601672
    602673/**
     674 * Changes the owner and/or group of a file system object.
     675 *
     676 * @returns iprt status code.
     677 * @param   pszPath     Path to the file system object.
     678 * @param   uid         The new file owner user id. Use -1 (or ~0) to leave this unchanged.
     679 * @param   gid         The new group id. Use -1 (or ~0) to leave this unchanged.
     680 * @param   fFlags      RTPATH_F_ON_LINK or RPATH_F_FOLLOW_LINK.
     681 */
     682RTR3DECL(int) RTPathSetOwnerEx(const char *pszPath, uint32_t uid, uint32_t gid, uint32_t fFlags);
     683
     684/**
    603685 * Gets the owner and/or group of a file system object.
    604686 *
     
    608690 * @param   pGid        Where to store the group id. NULL is ok.
    609691 *
    610  * @remark  This is wrapper around RTPathQueryInfo() and exists to complement RTPathGetOwner().
     692 * @remark  This is wrapper around RTPathQueryInfo() and exists to complement
     693 *          RTPathGetOwner().  If the last component is a symbolic link, it will
     694 *          not be resolved.
    611695 */
    612696RTR3DECL(int) RTPathGetOwner(const char *pszPath, uint32_t *pUid, uint32_t *pGid);
     
    622706 * Renames a path within a filesystem.
    623707 *
     708 * This will rename symbolic links.  If RTPATHRENAME_FLAGS_REPLACE is used and
     709 * pszDst is a symbolic link, it will be replaced and not its target.
     710 *
    624711 * @returns IPRT status code.
    625712 * @param   pszSrc      The source path.
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