Changeset 21675 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jul 17, 2009 12:18:30 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 50224
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 5 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r21674 r21675 234 234 common/misc/zip.cpp \ 235 235 common/misc/term.cpp \ 236 common/path/rtPathVolumeSpecLen.cpp \ 236 237 common/path/RTPathAbsDup.cpp \ 237 238 common/path/RTPathAbsEx.cpp \ … … 724 725 common/misc/sanity-c.c \ 725 726 common/misc/sanity-cpp.cpp \ 727 common/path/rtPathVolumeSpecLen.cpp \ 726 728 common/path/RTPathAbsDup.cpp \ 727 729 common/path/RTPathAbsEx.cpp \ … … 1106 1108 common/misc/sanity-cpp.cpp \ 1107 1109 common/misc/term.cpp \ 1110 common/path/rtPathVolumeSpecLen.cpp \ 1108 1111 common/path/RTPathAbsDup.cpp \ 1112 common/path/RTPathAbsEx.cpp \ 1113 common/path/RTPathAbsExDup.cpp \ 1109 1114 common/path/RTPathAppend.cpp \ 1110 1115 common/path/RTPathExt.cpp \ -
trunk/src/VBox/Runtime/common/path/RTPathAbsEx.cpp
r21673 r21675 38 38 #include <iprt/param.h> 39 39 #include <iprt/string.h> 40 #include "internal/ fs.h"40 #include "internal/path.h" 41 41 42 43 44 /**45 * Returns the length of the volume name specifier of the given path.46 * If no such specifier zero is returned.47 */48 size_t rtPathVolumeSpecLen(const char *pszPath)49 {50 #if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)51 if (pszPath && *pszPath)52 {53 /* UTC path. */54 /** @todo r=bird: it's UNC and we have to check that the next char isn't a55 * slash, then skip both the server and the share name. */56 if ( (pszPath[0] == '\\' || pszPath[0] == '/')57 && (pszPath[1] == '\\' || pszPath[1] == '/'))58 return strcspn(pszPath + 2, "\\/") + 2;59 60 /* Drive letter. */61 if ( pszPath[1] == ':'62 && toupper(pszPath[0]) >= 'A' && toupper(pszPath[0]) <= 'Z')63 return 2;64 }65 return 0;66 67 #else68 /* This isn't quite right when looking at the above stuff, but it works assuming that '//' does not mean UNC. */69 /// @todo (dmik) well, it's better to consider there's no volume name70 // at all on *nix systems71 return 0;72 // return pszPath && pszPath[0] == '/';73 #endif74 }75 42 76 43 -
trunk/src/VBox/Runtime/common/path/rtPathVolumeSpecLen.cpp
r21673 r21675 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - RTPathAbsEx3 * IPRT - rtPathVolumeSpecLen 4 4 */ 5 5 … … 34 34 *******************************************************************************/ 35 35 #include "internal/iprt.h" 36 #include <iprt/path.h>37 #include <iprt/err.h>38 #include <iprt/param.h>39 36 #include <iprt/string.h> 40 #include "internal/ fs.h"37 #include "internal/path.h" 41 38 42 39 … … 74 71 } 75 72 76 77 /**78 * Get the absolute path (no symlinks, no . or .. components), assuming the79 * given base path as the current directory. The resulting path doesn't have80 * to exist.81 *82 * @returns iprt status code.83 * @param pszBase The base path to act like a current directory.84 * When NULL, the actual cwd is used (i.e. the call85 * is equivalent to RTPathAbs(pszPath, ...).86 * @param pszPath The path to resolve.87 * @param pszAbsPath Where to store the absolute path.88 * @param cchAbsPath Size of the buffer.89 */90 RTDECL(int) RTPathAbsEx(const char *pszBase, const char *pszPath, char *pszAbsPath, size_t cchAbsPath)91 {92 if (pszBase && pszPath && !rtPathVolumeSpecLen(pszPath))93 {94 #if defined(RT_OS_WINDOWS)95 /* The format for very long paths is not supported. */96 if ( (pszBase[0] == '/' || pszBase[0] == '\\')97 && (pszBase[1] == '/' || pszBase[1] == '\\')98 && pszBase[2] == '?'99 && (pszBase[3] == '/' || pszBase[3] == '\\'))100 return VERR_INVALID_NAME;101 #endif102 103 /** @todo there are a couple of things which isn't 100% correct, although the104 * current code will have to work for now - I don't have time to fix it right now.105 *106 * 1) On Windows & OS/2 we confuse '/' with an abspath spec and will107 * not necessarily resolve it on the right drive.108 * 2) A trailing slash in the base might cause UNC names to be created.109 * 3) The lengths total doesn't have to be less than max length110 * if the pszPath starts with a slash.111 */112 size_t cchBase = strlen(pszBase);113 size_t cchPath = strlen(pszPath);114 if (cchBase + cchPath >= RTPATH_MAX)115 return VERR_FILENAME_TOO_LONG;116 117 bool fRootSpec = pszPath[0] == '/'118 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)119 || pszPath[0] == '\\'120 #endif121 ;122 size_t cchVolSpec = rtPathVolumeSpecLen(pszBase);123 char szPath[RTPATH_MAX];124 if (fRootSpec)125 {126 /* join the disk name from base and the path */127 memcpy(szPath, pszBase, cchVolSpec);128 strcpy(&szPath[cchVolSpec], pszPath);129 }130 else131 {132 /* join the base path and the path */133 strcpy(szPath, pszBase);134 szPath[cchBase] = RTPATH_DELIMITER;135 strcpy(&szPath[cchBase + 1], pszPath);136 }137 return RTPathAbs(szPath, pszAbsPath, cchAbsPath);138 }139 140 /* Fallback to the non *Ex version */141 return RTPathAbs(pszPath, pszAbsPath, cchAbsPath);142 }143 -
trunk/src/VBox/Runtime/include/internal/fs.h
r20374 r21675 45 45 bool rtFsModeIsValidPermissions(RTFMODE fMode); 46 46 47 size_t rtPathVolumeSpecLen(const char *pszPath);48 47 #ifndef RT_OS_WINDOWS 49 48 void rtFsConvertStatToObjInfo(PRTFSOBJINFO pObjInfo, const struct stat *pStat, const char *pszName, unsigned cbName); -
trunk/src/VBox/Runtime/include/internal/path.h
r20374 r21675 43 43 44 44 45 int rtPathPosixRename(const char *pszSrc, const char *pszDst, unsigned fRename, RTFMODE fFileType); 46 int rtPathWin32MoveRename(const char *pszSrc, const char *pszDst, uint32_t fFlags, RTFMODE fFileType); 45 size_t rtPathVolumeSpecLen(const char *pszPath); 46 int rtPathPosixRename(const char *pszSrc, const char *pszDst, unsigned fRename, RTFMODE fFileType); 47 int rtPathWin32MoveRename(const char *pszSrc, const char *pszDst, uint32_t fFlags, RTFMODE fFileType); 47 48 48 49 -
trunk/src/VBox/Runtime/r3/dir.cpp
r21486 r21675 52 52 #include <iprt/assert.h> 53 53 #include <iprt/uni.h> 54 #include "internal/fs.h"55 54 #include "internal/dir.h" 55 #include "internal/path.h" 56 56 57 57
Note:
See TracChangeset
for help on using the changeset viewer.