VirtualBox

Changeset 45400 in vbox


Ignore:
Timestamp:
Apr 8, 2013 12:08:00 PM (11 years ago)
Author:
vboxsync
Message:

IPRT: A Study in Paths - Chapter 3: Reassembling parsed and split paths.

Location:
trunk
Files:
2 added
4 edited

Legend:

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

    r45394 r45400  
    939939# define RTPathJoinEx                                   RT_MANGLER(RTPathJoinEx)
    940940# define RTPathParse                                    RT_MANGLER(RTPathParse)
     941# define RTPathParsedReassemble                         RT_MANGLER(RTPathParsedReassemble)
    941942# define RTPathParseSimple                              RT_MANGLER(RTPathParseSimple)
    942943# define RTPathQueryInfo                                RT_MANGLER(RTPathQueryInfo)
     
    956957# define RTPathSplitATag                                RT_MANGLER(RTPathSplitATag)
    957958# define RTPathSplitFree                                RT_MANGLER(RTPathSplitFree)
     959# define RTPathSplitReassemble                          RT_MANGLER(RTPathSplitReassemble)
    958960# define RTPathStartsWith                               RT_MANGLER(RTPathStartsWith)
    959961# define RTPathStartsWithRoot                           RT_MANGLER(RTPathStartsWithRoot)
  • trunk/include/iprt/path.h

    r45394 r45400  
    611611 * @sa      RTPathSplit, RTPathSplitA.
    612612 */
    613 RTDECL(int) RTPathParse(const char *pszPath,  PRTPATHPARSED pParsed, size_t cbParsed, uint32_t fFlags);
     613RTDECL(int) RTPathParse(const char *pszPath, PRTPATHPARSED pParsed, size_t cbParsed, uint32_t fFlags);
     614
     615/**
     616 * Reassembles a path parsed by RTPathParse.
     617 *
     618 * This will be more useful as more APIs manipulating the RTPATHPARSED output
     619 * are added.
     620 *
     621 * @returns IPRT status code.
     622 * @retval  VERR_BUFFER_OVERFLOW if @a cbDstPath is less than or equal to
     623 *          RTPATHPARSED::cchPath.
     624 *
     625 * @param   pszSrcPath          The source path.
     626 * @param   pParsed             The parser output for @a pszSrcPath.
     627 * @param   fFlags              Combination of RTPATH_STR_F_STYLE_XXX.
     628 *                              Most users will pass 0.
     629 * @param   pszDstPath          Pointer to the buffer where the path is to be
     630 *                              reassembled.
     631 * @param   cbDstPath           The size of the output buffer.
     632 */
     633RTDECL(int) RTPathParsedReassemble(const char *pszSrcPath, PRTPATHPARSED pParsed, uint32_t fFlags,
     634                                   char *pszDstPath, size_t cbDstPath);
     635
    614636
    615637/**
     
    691713 * @sa      RTPathSplitFree, RTPathSplit, RTPathParse.
    692714 */
    693 #define  RTPathSplitA(pszPath, ppSplit, fFlags)     RTPathSplitATag(pszPath, ppSplit, fFlags, RTPATH_TAG)
     715#define RTPathSplitA(pszPath, ppSplit, fFlags)      RTPathSplitATag(pszPath, ppSplit, fFlags, RTPATH_TAG)
    694716
    695717/**
     
    720742RTDECL(void) RTPathSplitFree(PRTPATHSPLIT pSplit);
    721743
     744/**
     745 * Reassembles a path parsed by RTPathSplit.
     746 *
     747 * This will be more useful as more APIs manipulating the RTPATHSPLIT output are
     748 * added.
     749 *
     750 * @returns IPRT status code.
     751 * @retval  VERR_BUFFER_OVERFLOW if @a cbDstPath is less than or equal to
     752 *          RTPATHSPLIT::cchPath.
     753 *
     754 * @param   pParsed             The parser output for @a pszSrcPath.
     755 * @param   fFlags              Combination of RTPATH_STR_F_STYLE_XXX.
     756 *                              Most users will pass 0.
     757 * @param   pszDstPath          Pointer to the buffer where the path is to be
     758 *                              reassembled.
     759 * @param   cbDstPath           The size of the output buffer.
     760 */
     761RTDECL(int) RTPathSplitReassemble(PRTPATHSPLIT pSplit, uint32_t fFlags, char *pszDstPath, size_t cbDstPath);
    722762
    723763/**
  • trunk/src/VBox/Runtime/Makefile.kmk

    r45394 r45400  
    363363        common/path/RTPathJoinEx.cpp \
    364364        common/path/RTPathParse.cpp \
     365        common/path/RTPathParsedReassemble.cpp \
    365366        common/path/RTPathParseSimple.cpp \
    366367        common/path/RTPathRealDup.cpp \
     
    368369        common/path/RTPathSplit.cpp \
    369370        common/path/RTPathSplitA.cpp \
     371        common/path/RTPathSplitReassemble.cpp \
    370372        common/path/RTPathStartsWithRoot.cpp \
    371373        common/path/RTPathStripExt.cpp \
  • trunk/src/VBox/Runtime/testcase/tstRTPath.cpp

    r45394 r45400  
    8787    };
    8888
     89    char szPath1[RTPATH_MAX];
    8990    union
    9091    {
     
    116117                                 s_aTests[i].offSuffix, u.Parsed.offSuffix,
    117118                                 s_aTests[i].cchPath,   u.Parsed.cchPath);
     119        }
     120        else
     121        {
     122            rc = RTPathParsedReassemble(s_aTests[i].pszPath, &u.Parsed, s_aTests[i].fFlags & ~RTPATH_STR_F_MIDDLE,
     123                                        szPath1, sizeof(szPath1));
     124            if (rc == VINF_SUCCESS)
     125            {
     126                RTTESTI_CHECK_MSG(strlen(szPath1) == s_aTests[i].cchPath, ("%s\n", szPath1));
     127                if (   !(u.Parsed.fProps & RTPATH_PROP_EXTRA_SLASHES)
     128                    && (s_aTests[i].fFlags & RTPATH_STR_F_STYLE_MASK) != RTPATH_STR_F_STYLE_DOS)
     129                    RTTESTI_CHECK_MSG(strcmp(szPath1, s_aTests[i].pszPath) == 0, ("%s\n", szPath1));
     130            }
     131            else
     132                RTTestIFailed("RTPathParsedReassemble -> %Rrc", rc);
    118133        }
    119134    }
     
    162177                RTPathSplitFree(pSplit);
    163178            }
     179
     180            rc = RTPathSplitReassemble(&u.Split, s_aTests[i].fFlags & ~RTPATH_STR_F_MIDDLE, szPath1, sizeof(szPath1));
     181            if (rc == VINF_SUCCESS)
     182            {
     183                RTTESTI_CHECK_MSG(strlen(szPath1) == s_aTests[i].cchPath, ("%s\n", szPath1));
     184                if (   !(u.Parsed.fProps & RTPATH_PROP_EXTRA_SLASHES)
     185                    && (s_aTests[i].fFlags & RTPATH_STR_F_STYLE_MASK) != RTPATH_STR_F_STYLE_DOS)
     186                    RTTESTI_CHECK_MSG(strcmp(szPath1, s_aTests[i].pszPath) == 0, ("%s\n", szPath1));
     187            }
     188            else
     189                RTTestIFailed("RTPathSplitReassemble -> %Rrc", rc);
    164190        }
    165191    }
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