VirtualBox

Changeset 45391 in vbox


Ignore:
Timestamp:
Apr 7, 2013 5:15:29 PM (11 years ago)
Author:
vboxsync
Message:

IPRT: Changed the RTPATHPARSE_FLAGS_ into generic ones as they will be shared with RTPathSplit*. Introduced a new character called RTPATH_STYLE with can have two values (currently) RTPATH_STR_F_STYLE_DOS or RTPATH_STR_F_STYLE_UNIX. Some other minor adjustments.

Location:
trunk
Files:
5 edited

Legend:

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

    r45389 r45391  
    5050#endif
    5151
    52 /** @def RTPATH_SLASH
    53  * The preferred slash character.
    54  *
    55  * @remark IPRT will always accept unix slashes. So, normally you would
    56  *         never have to use this define.
    57  */
    58 #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
    59 # define RTPATH_SLASH       '\\'
    60 #else
    61 # define RTPATH_SLASH       '/'
    62 #endif
    63 
    64 /** @deprecated Use '/'! */
    65 #define RTPATH_DELIMITER    RTPATH_SLASH
    66 
    67 
    68 /** @def RTPATH_SLASH_STR
    69  * The preferred slash character as a string, handy for concatenations
    70  * with other strings.
    71  *
    72  * @remark IPRT will always accept unix slashes. So, normally you would
    73  *         never have to use this define.
    74  */
    75 #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
    76 # define RTPATH_SLASH_STR   "\\"
    77 #else
    78 # define RTPATH_SLASH_STR   "/"
    79 #endif
    80 
    81 
    82 /** @def RTPATH_IS_SLASH
    83  * Checks if a character is a slash.
    84  *
    85  * @returns true if it's a slash and false if not.
    86  * @returns @param      ch      Char to check.
    87  */
    88 #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
    89 # define RTPATH_IS_SLASH(ch)    ( (ch) == '\\' || (ch) == '/' )
    90 #else
    91 # define RTPATH_IS_SLASH(ch)    ( (ch) == '/' )
    92 #endif
    93 
    94 
    95 /** @def RTPATH_IS_VOLSEP
    96  * Checks if a character marks the end of the volume specification.
    97  *
    98  * @remark  This is sufficient for the drive letter concept on PC.
    99  *          However it might be insufficient on other platforms
    100  *          and even on PC a UNC volume spec won't be detected this way.
    101  *          Use the RTPath@<too be created@>() instead.
    102  *
    103  * @returns true if it is and false if it isn't.
    104  * @returns @param      ch      Char to check.
    105  */
    106 #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
    107 # define RTPATH_IS_VOLSEP(ch)   ( (ch) == ':' )
    108 #else
    109 # define RTPATH_IS_VOLSEP(ch)   (false)
    110 #endif
    111 
    112 
    113 /** @def RTPATH_IS_SEP
    114  * Checks if a character is path component separator
    115  *
    116  * @returns true if it is and false if it isn't.
    117  * @returns @param      ch      Char to check.
    118  * @
    119  */
    120 #define RTPATH_IS_SEP(ch)       ( RTPATH_IS_SLASH(ch) || RTPATH_IS_VOLSEP(ch) )
    121 
    122 
    123 /** @name Generic RTPath flags
     52
     53/** @name RTPATH_F_XXX - Generic flags for APIs working on the file system.
    12454 * @{ */
    12555/** Last component: Work on the link. */
     
    13262/** @} */
    13363
    134 
    13564/** Validates a flags parameter containing RTPATH_F_*.
    13665 * @remarks The parameters will be referenced multiple times. */
    137 #define RTPATH_F_IS_VALID(fFlags, fIgnore) \
    138     (    ((fFlags) & ~(uint32_t)((fIgnore)|RTPATH_F_NO_SYMLINKS)) == RTPATH_F_ON_LINK \
    139       || ((fFlags) & ~(uint32_t)((fIgnore)|RTPATH_F_NO_SYMLINKS)) == RTPATH_F_FOLLOW_LINK )
     66#define RTPATH_F_IS_VALID(a_fFlags, a_fIgnore) \
     67    (    ((a_fFlags) & ~(uint32_t)((a_fIgnore) | RTPATH_F_NO_SYMLINKS)) == RTPATH_F_ON_LINK \
     68      || ((a_fFlags) & ~(uint32_t)((a_fIgnore) | RTPATH_F_NO_SYMLINKS)) == RTPATH_F_FOLLOW_LINK )
     69
     70
     71/** @name RTPATH_STR_F_XXX - Generic flags for APIs working with path strings.
     72 * @{
     73 */
     74/** Host OS path style (default 0 value). */
     75#define RTPATH_STR_F_STYLE_HOST         UINT32_C(0x00000000)
     76/** DOS, OS/2 and Windows path style. */
     77#define RTPATH_STR_F_STYLE_DOS          UINT32_C(0x00000001)
     78/** Unix path style. */
     79#define RTPATH_STR_F_STYLE_UNIX         UINT32_C(0x00000002)
     80/** Reserved path style. */
     81#define RTPATH_STR_F_STYLE_RESERVED     UINT32_C(0x00000003)
     82/** The path style mask. */
     83#define RTPATH_STR_F_STYLE_MASK         UINT32_C(0x00000003)
     84/** Partial path - no start.
     85 * This causes the API to skip the root specification parsing.  */
     86#define RTPATH_STR_F_NO_START           UINT32_C(0x00000010)
     87/** Partial path - no end.
     88 * This causes the API to skip the filename and dir-slash parsing.  */
     89#define RTPATH_STR_F_NO_END             UINT32_C(0x00000020)
     90/** Partial path - no start and no end. */
     91#define RTPATH_STR_F_MIDDLE             (RTPATH_STR_F_NO_START | RTPATH_STR_F_NO_END)
     92
     93/** Reserved for future use. */
     94#define RTPATH_STR_F_RESERVED_MASK      UINT32_C(0x0000ffcc)
     95/** @} */
     96
     97/** Validates a flags parameter containing RTPATH_FSTR_.
     98 * @remarks The parameters will be references multiple times.  */
     99#define RTPATH_STR_F_IS_VALID(a_fFlags, a_fIgnore) \
     100      (   ((a_fFlags) & ~((uint32_t)(a_fIgnore) | RTPATH_STR_F_STYLE_MASK | RTPATH_STR_F_MIDDLE)) == 0 \
     101       && ((a_fFlags) & RTPATH_STR_F_STYLE_MASK) != RTPATH_STR_F_STYLE_RESERVED \
     102       && ((a_fFlags) & RTPATH_STR_F_RESERVED_MASK) == 0 )
     103
     104
     105/** @def RTPATH_STYLE
     106 * The host path style. This is set to RTPATH_STR_F_STYLE_DOS,
     107 * RTPATH_STR_F_STYLE_UNIX, or other future styles. */
     108#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
     109# define RTPATH_STYLE       RTPATH_STR_F_STYLE_DOS
     110#else
     111# define RTPATH_STYLE       RTPATH_STR_F_STYLE_UNIX
     112#endif
     113
     114
     115/** @def RTPATH_SLASH
     116 * The preferred slash character.
     117 *
     118 * @remark IPRT will always accept unix slashes. So, normally you would
     119 *         never have to use this define.
     120 */
     121#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
     122# define RTPATH_SLASH       '\\'
     123#elif RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX
     124# define RTPATH_SLASH       '/'
     125#else
     126# error "Unsupported RTPATH_STYLE value."
     127#endif
     128
     129/** @deprecated Use '/'! */
     130#define RTPATH_DELIMITER    RTPATH_SLASH
     131
     132
     133/** @def RTPATH_SLASH_STR
     134 * The preferred slash character as a string, handy for concatenations
     135 * with other strings.
     136 *
     137 * @remark IPRT will always accept unix slashes. So, normally you would
     138 *         never have to use this define.
     139 */
     140#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
     141# define RTPATH_SLASH_STR   "\\"
     142#elif RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX
     143# define RTPATH_SLASH_STR   "/"
     144#else
     145# error "Unsupported RTPATH_STYLE value."
     146#endif
     147
     148
     149/** @def RTPATH_IS_SLASH
     150 * Checks if a character is a slash.
     151 *
     152 * @returns true if it's a slash and false if not.
     153 * @returns @param      a_ch    Char to check.
     154 */
     155#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
     156# define RTPATH_IS_SLASH(a_ch)      ( (a_ch) == '\\' || (a_ch) == '/' )
     157#elif RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX
     158# define RTPATH_IS_SLASH(a_ch)      ( (a_ch) == '/' )
     159#else
     160# error "Unsupported RTPATH_STYLE value."
     161#endif
     162
     163
     164/** @def RTPATH_IS_VOLSEP
     165 * Checks if a character marks the end of the volume specification.
     166 *
     167 * @remark  This is sufficient for the drive letter concept on PC.
     168 *          However it might be insufficient on other platforms
     169 *          and even on PC a UNC volume spec won't be detected this way.
     170 *          Use the RTPath@<too be created@>() instead.
     171 *
     172 * @returns true if it is and false if it isn't.
     173 * @returns @param      a_ch    Char to check.
     174 */
     175#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
     176# define RTPATH_IS_VOLSEP(a_ch)   ( (a_ch) == ':' )
     177#elif RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX
     178# define RTPATH_IS_VOLSEP(a_ch)   (false)
     179#else
     180# error "Unsupported RTPATH_STYLE value."
     181#endif
     182
     183
     184/** @def RTPATH_IS_SEP
     185 * Checks if a character is path component separator
     186 *
     187 * @returns true if it is and false if it isn't.
     188 * @returns @param      a_ch    Char to check.
     189 * @
     190 */
     191#define RTPATH_IS_SEP(a_ch)     ( RTPATH_IS_SLASH(a_ch) || RTPATH_IS_VOLSEP(a_ch) )
    140192
    141193
     
    543595 * @param   cbParsed            The size of the buffer. Must be at least the
    544596 *                              size of RTPATHPARSED.
    545  * @param   fFlags              Combination of RTPATHPARSE_FLAGS_XXX that can be
    546  *                              used to change how the start and end of the
    547  *                              path is parsed. Most users will pass 0.
     597 * @param   fFlags              Combination of RTPATH_STR_F_XXX flags.
     598 *                              Most users will pass 0.
    548599 * @sa      RTPathSplit, RTPathSplitA.
    549600 */
    550601RTDECL(int) RTPathParse(const char *pszPath,  PRTPATHPARSED pParsed, size_t cbParsed, uint32_t fFlags);
    551 
    552 /** @name RTPATHPARSE_FLAGS_XXX - RTPathParse flags.
    553  * @{ */
    554 /** Partial path - no start.
    555  * This causes RTPathParse to skip the root specification parsing.  */
    556 #define RTPATHPARSE_FLAGS_NO_START          RT_BIT_32(0)
    557 /** Partial path - no end.
    558  * This causes RTPathParse to skip the filename and dir-slash parsing.  */
    559 #define RTPATHPARSE_FLAGS_NO_END            RT_BIT_32(1)
    560 /** Partial path - no start and no end. */
    561 #define RTPATHPARSE_FLAGS_MIDDLE            (RTPATHPARSE_FLAGS_NO_START | RTPATHPARSE_FLAGS_NO_END)
    562 
    563 /** Host OS path style. */
    564 #define RTPATHPARSE_FLAGS_STYLE_HOST        UINT32_C(0x00000000)
    565 /** DOS, OS/2 and Windows path style. */
    566 #define RTPATHPARSE_FLAGS_STYLE_DOS         UINT32_C(0x00000010)
    567 /** Unix path style. */
    568 #define RTPATHPARSE_FLAGS_STYLE_UNIX        UINT32_C(0x00000020)
    569 /** Reserved path style. */
    570 #define RTPATHPARSE_FLAGS_STYLE_RESERVED    UINT32_C(0x00000030)
    571 /** The path style mask. */
    572 #define RTPATHPARSE_FLAGS_STYLE_MASK        UINT32_C(0x00000030)
    573 
    574 /** Mask containing the valid flags. */
    575 #define RTPATHPARSE_FLAGS_VALID_MASK        UINT32_C(0x00000033)
    576 /** @}  */
    577602
    578603/**
  • trunk/src/VBox/Runtime/common/path/RTPathParse.cpp

    r45390 r45391  
    5050    AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
    5151    AssertReturn(*pszPath, VERR_PATH_ZERO_LENGTH);
    52     AssertReturn(!(fFlags & ~RTPATHPARSE_FLAGS_VALID_MASK), VERR_INVALID_FLAGS);
     52    AssertReturn(RTPATH_STR_F_IS_VALID(fFlags, 0), VERR_INVALID_FLAGS);
    5353
    5454    /*
    5555     * Invoke the worker for the selected path style.
    5656     */
    57     switch (fFlags & RTPATHPARSE_FLAGS_STYLE_MASK)
     57    switch (fFlags & RTPATH_STR_F_STYLE_MASK)
    5858    {
    5959#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
    60         case RTPATHPARSE_FLAGS_STYLE_HOST:
     60        case RTPATH_STR_F_STYLE_HOST:
    6161#endif
    62         case RTPATHPARSE_FLAGS_STYLE_DOS:
     62        case RTPATH_STR_F_STYLE_DOS:
    6363            return rtPathParseStyleDos(pszPath, pParsed, cbParsed, fFlags);
    6464
    6565#if !defined(RT_OS_OS2) && !defined(RT_OS_WINDOWS)
    66         case RTPATHPARSE_FLAGS_STYLE_HOST:
     66        case RTPATH_STR_F_STYLE_HOST:
    6767#endif
    68         case RTPATHPARSE_FLAGS_STYLE_UNIX:
     68        case RTPATH_STR_F_STYLE_UNIX:
    6969            return rtPathParseStyleUnix(pszPath, pParsed, cbParsed, fFlags);
    7070
    7171        default:
    72             AssertFailedReturn(VERR_INVALID_FLAGS);
     72            AssertFailedReturn(VERR_INVALID_FLAGS); /* impossible */
    7373    }
    7474}
  • trunk/src/VBox/Runtime/common/path/RTPathParse.cpp.h

    r45389 r45391  
    4848    if (RTPATH_IS_SLASH(pszPath[0]))
    4949    {
    50         if (fFlags & RTPATHPARSE_FLAGS_NO_START)
     50        if (fFlags & RTPATH_STR_F_NO_START)
    5151        {
    5252            offCur = 1;
     
    5858            cchPath = 0;
    5959        }
    60 #ifdef RTPATH_STYLE_DOS
     60#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
    6161        else if (   RTPATH_IS_SLASH(pszPath[1])
    6262                 && !RTPATH_IS_SLASH(pszPath[2])
     
    8484        else
    8585        {
    86 #ifdef RTPATH_STYLE_DOS
     86#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
    8787            fProps = RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_RELATIVE;
    8888#else
     
    9292        }
    9393    }
    94 #ifdef RTPATH_STYLE_DOS
     94#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
    9595    else if (RT_C_IS_ALPHA(pszPath[0]) && pszPath[1] == ':')
    9696    {
     
    115115
    116116    /*  Add it to the component array . */
    117     if (offCur && !(fFlags & RTPATHPARSE_FLAGS_NO_START))
     117    if (offCur && !(fFlags & RTPATH_STR_F_NO_START))
    118118    {
    119119        cchPath = offCur;
     
    192192                if (ch)
    193193                {
    194                     if (!(fFlags & RTPATHPARSE_FLAGS_NO_END))
     194                    if (!(fFlags & RTPATH_STR_F_NO_END))
    195195                        fProps |= RTPATH_PROP_DIR_SLASH; /* (not counted) */
    196196                    else
    197197                        fProps |= RTPATH_PROP_EXTRA_SLASHES;
    198198                }
    199                 else if (!(fFlags & RTPATHPARSE_FLAGS_NO_END))
     199                else if (!(fFlags & RTPATH_STR_F_NO_END))
    200200                {
    201201                    fProps |= RTPATH_PROP_FILENAME;
  • trunk/src/VBox/Runtime/common/path/rtpath-expand-template.cpp.h

    r45389 r45391  
    2626 */
    2727
     28#undef  RTPATH_DELIMITER
    2829
    2930/*
    30  * The following should move to a helper header!
     31 * DOS style
    3132 */
    32 #undef  RTPATH_DELIMITER
    33 
    34 /* DOS style */
    35 #undef  RTPATH_STYLE_UNIX
    36 #undef  RTPATH_STYLE_DOS
     33#undef  RTPATH_STYLE
     34#undef  RTPATH_SLASH
    3735#undef  RTPATH_SLASH_STR
    3836#undef  RTPATH_IS_SLASH
     
    4038#undef  RTPATH_STYLE_FN
    4139
    42 #define RTPATH_STYLE_DOS
     40#define RTPATH_STYLE            RTPATH_STR_F_STYLE_DOS
     41#define RTPATH_SLASH            '\\'
    4342#define RTPATH_SLASH_STR        "\\"
    4443#define RTPATH_IS_SLASH(a_ch)   ( (a_ch) == '\\' || (a_ch) == '/' )
     
    4746#include RTPATH_TEMPLATE_CPP_H
    4847
    49 /* Unix style. */
    50 #undef  RTPATH_STYLE_UNIX
    51 #undef  RTPATH_STYLE_DOS
     48/*
     49 * Unix style.
     50 */
     51#undef  RTPATH_STYLE
     52#undef  RTPATH_SLASH
    5253#undef  RTPATH_SLASH_STR
    5354#undef  RTPATH_IS_SLASH
     
    5556#undef  RTPATH_STYLE_FN
    5657
    57 #define RTPATH_STYLE_UNIX
     58#define RTPATH_STYLE            RTPATH_STR_F_STYLE_UNIX
     59#define RTPATH_SLASH            '/'
    5860#define RTPATH_SLASH_STR        "/"
    5961#define RTPATH_IS_SLASH(a_ch)   ( (a_ch) == '/' )
     
    6264#include RTPATH_TEMPLATE_CPP_H
    6365
    64 /* Restore original style. */
     66/*
     67 * Clean up and restore the host style.
     68 */
    6569#undef RTPATH_STYLE_FN
    6670#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
    67 # undef  RTPATH_STYLE_UNIX
    68 # undef  RTPATH_STYLE_DOS
     71# undef  RTPATH_STYLE
    6972# undef  RTPATH_SLASH_STR
    7073# undef  RTPATH_IS_SLASH
    7174# undef  RTPATH_IS_VOLSEP
    72 # define RTPATH_SLASH_STR        "\\"
    73 # define RTPATH_IS_SLASH(a_ch)   ( (a_ch) == '\\' || (a_ch) == '/' )
    74 # define RTPATH_IS_VOLSEP(a_ch)  ( (a_ch) == ':' )
     75# define RTPATH_STYLE           RTPATH_STR_F_STYLE_DOS
     76# define RTPATH_SLASH           '\\'
     77# define RTPATH_SLASH_STR       "\\"
     78# define RTPATH_IS_SLASH(a_ch)  ( (a_ch) == '\\' || (a_ch) == '/' )
     79# define RTPATH_IS_VOLSEP(a_ch) ( (a_ch) == ':' )
    7580#endif
    7681
  • trunk/src/VBox/Runtime/testcase/tstRTPath.cpp

    r45389 r45391  
    5353    } const s_aTests[] =
    5454    {
    55         { 2, 13,  9,  "C:/Config.sys",    RTPATH_PROP_VOLUME | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX,       RTPATHPARSE_FLAGS_STYLE_DOS },
    56         { 2, 13, 10,  "C://Config.sys",   RTPATH_PROP_VOLUME | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX | RTPATH_PROP_EXTRA_SLASHES, RTPATHPARSE_FLAGS_STYLE_DOS },
    57         { 2, 12,  8,  "C:Config.sys",     RTPATH_PROP_VOLUME | RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX,                                RTPATHPARSE_FLAGS_STYLE_DOS },
    58         { 1, 10,  6,  "Config.sys",       RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX,                                                     RTPATHPARSE_FLAGS_STYLE_DOS },
    59         { 1,  4,  4,  "//./",             RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE,                                                      RTPATHPARSE_FLAGS_STYLE_DOS },
    60         { 2,  5,  5,  "//./f",            RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                               RTPATHPARSE_FLAGS_STYLE_DOS },
    61         { 2,  5,  6,  "//.//f",           RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_EXTRA_SLASHES,   RTPATHPARSE_FLAGS_STYLE_DOS },
    62         { 3,  7,  7,  "//././f",          RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_DOT_REFS,        RTPATHPARSE_FLAGS_STYLE_DOS },
    63         { 3,  8,  8,  "//.././f",         RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_DOT_REFS,        RTPATHPARSE_FLAGS_STYLE_DOS },
    64         { 3,  9,  9,  "//../../f",        RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME | RTPATH_PROP_DOTDOT_REFS,     RTPATHPARSE_FLAGS_STYLE_DOS },
    65         { 1,  1,  1,  "/",                RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE,                                                                        RTPATHPARSE_FLAGS_STYLE_UNIX },
    66         { 2,  4,  4,  "/bin",             RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATHPARSE_FLAGS_STYLE_UNIX },
    67         { 2,  4,  5,  "/bin/",            RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_DIR_SLASH,                                                RTPATHPARSE_FLAGS_STYLE_UNIX },
    68         { 3,  7,  7,  "/bin/ls",          RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATHPARSE_FLAGS_STYLE_UNIX },
    69         { 3,  12, 7,  "/etc/rc.conf",     RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX,                            RTPATHPARSE_FLAGS_STYLE_UNIX },
    70         { 1,  1,  2,  "//",               RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_EXTRA_SLASHES,                                            RTPATHPARSE_FLAGS_STYLE_UNIX },
    71         { 1,  1,  3,  "///",              RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_EXTRA_SLASHES,                                            RTPATHPARSE_FLAGS_STYLE_UNIX },
    72         { 3,  6,  7,  "/.//bin",          RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_EXTRA_SLASHES | RTPATH_PROP_DOT_REFS | RTPATH_PROP_FILENAME, RTPATHPARSE_FLAGS_STYLE_UNIX },
    73         { 1,  3,  3,  "bin",              RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME,                                                                          RTPATHPARSE_FLAGS_STYLE_UNIX },
    74         { 1,  3,  4,  "bin/",             RTPATH_PROP_RELATIVE | RTPATH_PROP_DIR_SLASH,                                                                         RTPATHPARSE_FLAGS_STYLE_UNIX },
    75         { 1,  3,  7,  "bin////",          RTPATH_PROP_RELATIVE | RTPATH_PROP_DIR_SLASH | RTPATH_PROP_EXTRA_SLASHES,                                             RTPATHPARSE_FLAGS_STYLE_UNIX },
    76         { 3, 10, 10,  "bin/../usr",       RTPATH_PROP_RELATIVE | RTPATH_PROP_DOTDOT_REFS | RTPATH_PROP_FILENAME,                                                RTPATHPARSE_FLAGS_STYLE_UNIX },
    77         { 4, 11, 11,  "/bin/../usr",      RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_RELATIVE | RTPATH_PROP_DOTDOT_REFS | RTPATH_PROP_FILENAME,                       RTPATHPARSE_FLAGS_STYLE_UNIX },
    78         { 4,  8,  8,  "/a/.../u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATHPARSE_FLAGS_STYLE_UNIX },
    79         { 4,  8,  8,  "/a/.b./u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATHPARSE_FLAGS_STYLE_UNIX },
    80         { 4,  8,  8,  "/a/..c/u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATHPARSE_FLAGS_STYLE_UNIX },
    81         { 4,  8,  8,  "/a/d../u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATHPARSE_FLAGS_STYLE_UNIX },
    82         { 4,  8,  8,  "/a/.e/.u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATHPARSE_FLAGS_STYLE_UNIX },
    83         { 4,  8,  8,  "/a/.f/.u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATHPARSE_FLAGS_STYLE_UNIX },
    84         { 4,  8,  8,  "/a/.g/u.",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATHPARSE_FLAGS_STYLE_UNIX },
    85         { 3,  9, 10,  "/a/h/u.ext",       RTPATH_PROP_EXTRA_SLASHES | RTPATH_PROP_RELATIVE,                                                                     RTPATHPARSE_FLAGS_STYLE_UNIX | RTPATHPARSE_FLAGS_MIDDLE },
    86         { 3,  9,  9,  "a/h/u.ext",        RTPATH_PROP_RELATIVE,                                                                                                 RTPATHPARSE_FLAGS_STYLE_UNIX | RTPATHPARSE_FLAGS_MIDDLE },
    87         { 3,  9, 10,  "a/h/u.ext/",       RTPATH_PROP_EXTRA_SLASHES | RTPATH_PROP_RELATIVE,                                                                     RTPATHPARSE_FLAGS_STYLE_UNIX | RTPATHPARSE_FLAGS_MIDDLE },
     55        { 2, 13,  9,  "C:/Config.sys",    RTPATH_PROP_VOLUME | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX,       RTPATH_STR_F_STYLE_DOS },
     56        { 2, 13, 10,  "C://Config.sys",   RTPATH_PROP_VOLUME | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX | RTPATH_PROP_EXTRA_SLASHES, RTPATH_STR_F_STYLE_DOS },
     57        { 2, 12,  8,  "C:Config.sys",     RTPATH_PROP_VOLUME | RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX,                                RTPATH_STR_F_STYLE_DOS },
     58        { 1, 10,  6,  "Config.sys",       RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX,                                                     RTPATH_STR_F_STYLE_DOS },
     59        { 1,  4,  4,  "//./",             RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE,                                                      RTPATH_STR_F_STYLE_DOS },
     60        { 2,  5,  5,  "//./f",            RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                               RTPATH_STR_F_STYLE_DOS },
     61        { 2,  5,  6,  "//.//f",           RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_EXTRA_SLASHES,   RTPATH_STR_F_STYLE_DOS },
     62        { 3,  7,  7,  "//././f",          RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_DOT_REFS,        RTPATH_STR_F_STYLE_DOS },
     63        { 3,  8,  8,  "//.././f",         RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_DOT_REFS,        RTPATH_STR_F_STYLE_DOS },
     64        { 3,  9,  9,  "//../../f",        RTPATH_PROP_UNC | RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME | RTPATH_PROP_DOTDOT_REFS,     RTPATH_STR_F_STYLE_DOS },
     65        { 1,  1,  1,  "/",                RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE,                                                                        RTPATH_STR_F_STYLE_UNIX },
     66        { 2,  4,  4,  "/bin",             RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATH_STR_F_STYLE_UNIX },
     67        { 2,  4,  5,  "/bin/",            RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_DIR_SLASH,                                                RTPATH_STR_F_STYLE_UNIX },
     68        { 3,  7,  7,  "/bin/ls",          RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATH_STR_F_STYLE_UNIX },
     69        { 3,  12, 7,  "/etc/rc.conf",     RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME | RTPATH_PROP_SUFFIX,                            RTPATH_STR_F_STYLE_UNIX },
     70        { 1,  1,  2,  "//",               RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_EXTRA_SLASHES,                                            RTPATH_STR_F_STYLE_UNIX },
     71        { 1,  1,  3,  "///",              RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_EXTRA_SLASHES,                                            RTPATH_STR_F_STYLE_UNIX },
     72        { 3,  6,  7,  "/.//bin",          RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_EXTRA_SLASHES | RTPATH_PROP_DOT_REFS | RTPATH_PROP_FILENAME, RTPATH_STR_F_STYLE_UNIX },
     73        { 1,  3,  3,  "bin",              RTPATH_PROP_RELATIVE | RTPATH_PROP_FILENAME,                                                                          RTPATH_STR_F_STYLE_UNIX },
     74        { 1,  3,  4,  "bin/",             RTPATH_PROP_RELATIVE | RTPATH_PROP_DIR_SLASH,                                                                         RTPATH_STR_F_STYLE_UNIX },
     75        { 1,  3,  7,  "bin////",          RTPATH_PROP_RELATIVE | RTPATH_PROP_DIR_SLASH | RTPATH_PROP_EXTRA_SLASHES,                                             RTPATH_STR_F_STYLE_UNIX },
     76        { 3, 10, 10,  "bin/../usr",       RTPATH_PROP_RELATIVE | RTPATH_PROP_DOTDOT_REFS | RTPATH_PROP_FILENAME,                                                RTPATH_STR_F_STYLE_UNIX },
     77        { 4, 11, 11,  "/bin/../usr",      RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_RELATIVE | RTPATH_PROP_DOTDOT_REFS | RTPATH_PROP_FILENAME,                       RTPATH_STR_F_STYLE_UNIX },
     78        { 4,  8,  8,  "/a/.../u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATH_STR_F_STYLE_UNIX },
     79        { 4,  8,  8,  "/a/.b./u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATH_STR_F_STYLE_UNIX },
     80        { 4,  8,  8,  "/a/..c/u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATH_STR_F_STYLE_UNIX },
     81        { 4,  8,  8,  "/a/d../u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATH_STR_F_STYLE_UNIX },
     82        { 4,  8,  8,  "/a/.e/.u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATH_STR_F_STYLE_UNIX },
     83        { 4,  8,  8,  "/a/.f/.u",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATH_STR_F_STYLE_UNIX },
     84        { 4,  8,  8,  "/a/.g/u.",         RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_ABSOLUTE | RTPATH_PROP_FILENAME,                                                 RTPATH_STR_F_STYLE_UNIX },
     85        { 3,  9, 10,  "/a/h/u.ext",       RTPATH_PROP_EXTRA_SLASHES | RTPATH_PROP_RELATIVE,                                                                     RTPATH_STR_F_STYLE_UNIX | RTPATH_STR_F_MIDDLE },
     86        { 3,  9,  9,  "a/h/u.ext",        RTPATH_PROP_RELATIVE,                                                                                                 RTPATH_STR_F_STYLE_UNIX | RTPATH_STR_F_MIDDLE },
     87        { 3,  9, 10,  "a/h/u.ext/",       RTPATH_PROP_EXTRA_SLASHES | RTPATH_PROP_RELATIVE,                                                                     RTPATH_STR_F_STYLE_UNIX | RTPATH_STR_F_MIDDLE },
    8888    };
    8989
     
    131131        return rc;
    132132    RTTestBanner(hTest);
     133
     134    RTTestSub(hTest, "Environment");
     135#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
     136    RTTESTI_CHECK(RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS);
     137# if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
     138# else
     139    RTTestIFailed("#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS");
     140# endif
     141    RTTESTI_CHECK(strcmp(RTPATH_SLASH_STR, "\\") == 0);
     142    RTTESTI_CHECK(RTPATH_SLASH == '\\');
     143    RTTESTI_CHECK(RTPATH_IS_SEP('/'));
     144    RTTESTI_CHECK(RTPATH_IS_SEP('\\'));
     145    RTTESTI_CHECK(RTPATH_IS_SEP(':'));
     146
     147#else
     148    RTTESTI_CHECK(RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX);
     149# if RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX
     150# else
     151    RTTestIFailed("#if RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX");
     152# endif
     153    RTTESTI_CHECK(strcmp(RTPATH_SLASH_STR, "/") == 0);
     154    RTTESTI_CHECK(RTPATH_SLASH == '/');
     155    RTTESTI_CHECK(RTPATH_IS_SEP('/'));
     156    RTTESTI_CHECK(!RTPATH_IS_SEP('\\'));
     157    RTTESTI_CHECK(!RTPATH_IS_SEP(':'));
     158#endif
    133159
    134160    /*
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