VirtualBox

Changeset 98725 in vbox


Ignore:
Timestamp:
Feb 24, 2023 2:48:07 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
156025
Message:

Guest Control/Main: Fixed deleting files via built-in toolbox; GuestToolboxStreamBlock::GetVrc() returns VERR_NOT_FOUND when the stream block key "rc" was not found. However, some IPRT-provided tools, such as RTPathRmCmd(), only output rc on failure but not on success (exit code 0).

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h

    r98709 r98725  
    10201020    const char *GetString(const char *pszKey) const;
    10211021    size_t      GetCount(void) const;
    1022     int         GetVrc(void) const;
     1022    int         GetVrc(bool fSucceedIfNotFound = false) const;
    10231023    int         GetInt64Ex(const char *pszKey, int64_t *piVal) const;
    10241024    int64_t     GetInt64(const char *pszKey) const;
  • trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp

    r98666 r98725  
    429429#endif
    430430    /* Object name. */
    431     mName = strmBlk.GetString("fname");
     431    mName = strmBlk.GetString("fname"); /* Note: RTPathRmCmd() only sets this on failure. */
    432432
    433433    /* Return the stream block's vrc. */
    434     return strmBlk.GetVrc();
     434    return strmBlk.GetVrc(true /* fSucceedIfNotFound */);
    435435}
    436436
     
    597597 * @return  VBox status code.
    598598 * @retval  VERR_NOT_FOUND if the return code string ("rc") was not found.
    599  */
    600 int GuestToolboxStreamBlock::GetVrc(void) const
     599 * @param   fSucceedIfNotFound  When set to @c true, this reports back VINF_SUCCESS when the key ("rc") is not found.
     600 *                              This can happen with some (older) IPRT-provided tools such as RTPathRmCmd(), which only outputs
     601 *                              rc on failure but not on success. Defaults to @c false.
     602 */
     603int GuestToolboxStreamBlock::GetVrc(bool fSucceedIfNotFound /* = false */) const
    601604{
    602605    const char *pszValue = GetString("rc");
    603606    if (pszValue)
    604607        return RTStrToInt16(pszValue);
     608    if (fSucceedIfNotFound)
     609        return VINF_SUCCESS;
    605610    /** @todo We probably should have a dedicated error for that, VERR_GSTCTL_GUEST_TOOLBOX_whatever. */
    606611    return VERR_NOT_FOUND;
Note: See TracChangeset for help on using the changeset viewer.

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