Changeset 80832 in vbox for trunk/src/VBox/Runtime/common/path
- Timestamp:
- Sep 16, 2019 6:10:52 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 133402
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/path/RTPathEnsureTrailingSeparator.cpp
r76553 r80832 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - RTPathEnsureTrailingSeparator 3 * IPRT - RTPathEnsureTrailingSeparator & RTPathEnsureTrailingSeparatorEx 4 4 */ 5 5 … … 31 31 #include "internal/iprt.h" 32 32 #include <iprt/path.h> 33 34 #include <iprt/assert.h> 35 #include <iprt/ctype.h> 33 36 #include <iprt/string.h> 34 #include <iprt/ctype.h>35 37 36 38 39 /********************************************************************************************************************************* 40 * Global Variables * 41 *********************************************************************************************************************************/ 42 /** Slash character indexed by path style. */ 43 static char g_achSlashes[] = 44 { 45 /*[RTPATH_STR_F_STYLE_HOST] =*/ RTPATH_SLASH, 46 /*[RTPATH_STR_F_STYLE_DOS] =*/ '\\', 47 /*[RTPATH_STR_F_STYLE_UNIX] =*/ '/', 48 /*[RTPATH_STR_F_STYLE_RESERVED] =*/ '!', 49 }; 50 AssertCompile(RTPATH_STR_F_STYLE_HOST == 0); 51 AssertCompile(RTPATH_STR_F_STYLE_DOS == 1); 52 AssertCompile(RTPATH_STR_F_STYLE_UNIX == 2); 37 53 38 RTDECL(size_t) RTPathEnsureTrailingSeparator(char *pszPath, size_t cbPath) 54 55 RTDECL(size_t) RTPathEnsureTrailingSeparatorEx(char *pszPath, size_t cbPath, uint32_t fFlags) 39 56 { 57 Assert(RTPATH_STR_F_IS_VALID(fFlags, 0)); 58 40 59 size_t off = strlen(pszPath); 41 60 if (off > 0) 42 61 { 43 62 char ch = pszPath[off - 1]; 44 if ( RTPATH_IS_SLASH(ch) || RTPATH_IS_VOLSEP(ch))63 if (ch == '/') 45 64 return off; 65 if ( (ch == ':' || ch == '\\') 66 && ( (fFlags & RTPATH_STR_F_STYLE_MASK) == RTPATH_STR_F_STYLE_DOS 67 #if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS 68 || (fFlags & RTPATH_STR_F_STYLE_MASK) == RTPATH_STR_F_STYLE_HOST 69 #endif 70 )) 71 return off; 72 46 73 if (off + 2 <= cbPath) 47 74 { 48 pszPath[off++] = RTPATH_SLASH;75 pszPath[off++] = g_achSlashes[fFlags & RTPATH_STR_F_STYLE_MASK]; 49 76 pszPath[off] = '\0'; 50 77 return off; … … 54 81 { 55 82 pszPath[off++] = '.'; 56 pszPath[off++] = RTPATH_SLASH;83 pszPath[off++] = g_achSlashes[fFlags & RTPATH_STR_F_STYLE_MASK]; 57 84 pszPath[off] = '\0'; 58 85 return off; … … 61 88 return 0; 62 89 } 90 RT_EXPORT_SYMBOL(RTPathEnsureTrailingSeparatorEx); 91 92 93 RTDECL(size_t) RTPathEnsureTrailingSeparator(char *pszPath, size_t cbPath) 94 { 95 return RTPathEnsureTrailingSeparatorEx(pszPath, cbPath, RTPATH_STR_F_STYLE_HOST); 96 } 63 97 RT_EXPORT_SYMBOL(RTPathEnsureTrailingSeparator); 64 98
Note:
See TracChangeset
for help on using the changeset viewer.