Changeset 46104 in vbox
- Timestamp:
- May 15, 2013 5:12:14 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r46101 r46104 957 957 # define RTPathExt RT_MANGLER(RTPathExt) 958 958 # define RTPathFilename RT_MANGLER(RTPathFilename) 959 # define RTPathFilenameEx RT_MANGLER(RTPathFilenameEx) 959 960 # define RTPathGetCurrent RT_MANGLER(RTPathGetCurrent) 960 961 # define RTPathGetMode RT_MANGLER(RTPathGetMode) -
trunk/include/iprt/path.h
r45400 r46104 384 384 */ 385 385 RTDECL(char *) RTPathFilename(const char *pszPath); 386 387 /** 388 * Finds the filename in a path, extended version. 389 * 390 * @returns Pointer to filename within pszPath. 391 * @returns NULL if no filename (i.e. empty string or ends with a slash). 392 * @param pszPath Path to find filename in. 393 * @param fFlags RTPATH_STR_F_STYLE_XXX. Other RTPATH_STR_F_XXX flags 394 * will be ignored. 395 */ 396 RTDECL(char *) RTPathFilenameEx(const char *pszPath, uint32_t fFlags); 386 397 387 398 /** -
trunk/src/VBox/Runtime/common/path/RTPathFilename.cpp
r44528 r46104 31 31 #include "internal/iprt.h" 32 32 #include <iprt/path.h> 33 #include <iprt/string.h> 33 34 #include <iprt/assert.h> 34 35 35 36 36 37 37 /**38 * Finds the filename in a path.39 *40 * @returns Pointer to filename within pszPath.41 * @returns NULL if no filename (i.e. empty string or ends with a slash).42 * @param pszPath Path to find filename in.43 */44 38 RTDECL(char *) RTPathFilename(const char *pszPath) 39 { 40 return RTPathFilenameEx(pszPath, RTPATH_STYLE); 41 } 42 RT_EXPORT_SYMBOL(RTPathFilename); 43 44 45 RTDECL(char *) RTPathFilenameEx(const char *pszPath, uint32_t fFlags) 45 46 { 46 47 const char *psz = pszPath; 47 48 const char *pszName = pszPath; 48 49 49 for (;; psz++) 50 Assert(RTPATH_STR_F_IS_VALID(fFlags, 0 /*no extra flags*/)); 51 fFlags &= RTPATH_STR_F_STYLE_MASK; 52 if (fFlags == RTPATH_STR_F_STYLE_HOST) 53 fFlags = RTPATH_STYLE; 54 if (fFlags == RTPATH_STR_F_STYLE_DOS) 50 55 { 51 switch (*psz)56 for (;; psz++) 52 57 { 53 /* handle separators. */ 54 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) 55 case ':': 56 pszName = psz + 1; 57 break; 58 switch (*psz) 59 { 60 /* handle separators. */ 61 case ':': 62 case '\\': 63 case '/': 64 pszName = psz + 1; 65 break; 58 66 59 case '\\': 60 #endif 61 case '/': 62 pszName = psz + 1; 63 break; 67 /* the end */ 68 case '\0': 69 if (*pszName) 70 return (char *)(void *)pszName; 71 return NULL; 72 } 73 } 74 } 75 else 76 { 77 Assert(fFlags == RTPATH_STR_F_STYLE_UNIX); 78 for (;; psz++) 79 { 80 switch (*psz) 81 { 82 /* handle separators. */ 83 case '/': 84 pszName = psz + 1; 85 break; 64 86 65 /* the end */ 66 case '\0': 67 if (*pszName) 68 return (char *)(void *)pszName; 69 return NULL; 87 /* the end */ 88 case '\0': 89 if (*pszName) 90 return (char *)(void *)pszName; 91 return NULL; 92 } 70 93 } 71 94 } … … 73 96 /* not reached */ 74 97 } 98 RT_EXPORT_SYMBOL(RTPathFilenameEx); 75 99 100
Note:
See TracChangeset
for help on using the changeset viewer.