Changeset 79421 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jun 28, 2019 8:34:58 PM (6 years ago)
- Location:
- trunk/src/VBox/Runtime/r3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/dir.cpp
r78207 r79421 59 59 RTDECL(int) RTDirCreateFullPath(const char *pszPath, RTFMODE fMode) 60 60 { 61 return RTDirCreateFullPathEx(pszPath, fMode, 0); 62 } 63 64 65 RTDECL(int) RTDirCreateFullPathEx(const char *pszPath, RTFMODE fMode, uint32_t fFlags) 66 { 61 67 /* 62 68 * Resolve the path. 63 69 */ 64 char szAbsPath[RTPATH_MAX]; 65 int rc = RTPathAbs(pszPath, szAbsPath, sizeof(szAbsPath)); 66 if (RT_FAILURE(rc)) 67 return rc; 70 char *pszAbsPath = RTPathAbsDup(pszPath); 71 if (!pszAbsPath) 72 return VERR_NO_TMP_MEMORY; 68 73 69 74 /* … … 71 76 */ 72 77 /* skip volume name */ 73 char *psz = & szAbsPath[rtPathVolumeSpecLen(szAbsPath)];78 char *psz = &pszAbsPath[rtPathVolumeSpecLen(pszAbsPath)]; 74 79 75 80 /* skip the root slash if any */ 76 if ( psz[0] == '/' 77 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) 78 || psz[0] == '\\' 79 #endif 80 ) 81 if (RTPATH_IS_SLASH(*psz)) 81 82 psz++; 82 83 83 84 /* iterate over path components. */ 85 int rc = VINF_SUCCESS; 84 86 do 85 87 { … … 87 89 if (!*psz) 88 90 break; 89 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) 90 psz = strpbrk(psz, "\\/"); 91 #if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS 92 char *psz2 = strchr(psz, '/'); 93 psz = strchr(psz, RTPATH_SLASH); 94 if (psz2 && (!psz || (uintptr_t)psz2 < (uintptr_t)psz)) 95 psz = psz; 91 96 #else 92 psz = strchr(psz, '/');97 psz = strchr(psz, RTPATH_SLASH); 93 98 #endif 94 99 if (psz) 95 100 *psz = '\0'; 101 96 102 /* 97 103 * ASSUME that RTDirCreate will return VERR_ALREADY_EXISTS and not VERR_ACCESS_DENIED in those cases 98 104 * where the directory exists but we don't have write access to the parent directory. 99 105 */ 100 rc = RTDirCreate( szAbsPath, fMode, 0);106 rc = RTDirCreate(pszAbsPath, fMode, fFlags); 101 107 if (rc == VERR_ALREADY_EXISTS) 102 108 rc = VINF_SUCCESS; 109 103 110 if (!psz) 104 111 break; … … 106 113 } while (RT_SUCCESS(rc)); 107 114 115 RTStrFree(pszAbsPath); 108 116 return rc; 109 117 } -
trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp
r79155 r79421 91 91 if (RT_SUCCESS(rc)) 92 92 { 93 struct stat st; 93 94 if (mkdir(pszNativePath, fMode & RTFS_UNIX_MASK) == 0) 95 { 96 /* If requested, we try make use the permission bits are set 97 correctly when asked. For now, we'll just ignore errors here. */ 98 if (fCreate & RTDIRCREATE_FLAGS_IGNORE_UMASK) 99 { 100 if ( stat(pszNativePath, &st) 101 || (st.st_mode & 07777) != (fMode & 07777) ) 102 chmod(pszNativePath, fMode & RTFS_UNIX_MASK); 103 } 94 104 rc = VINF_SUCCESS; 105 } 95 106 else 96 107 { … … 109 120 rc = RTErrConvertFromErrno(rc); 110 121 /*fVerifyIsDir = false; We'll check if it's a dir ourselves since we're going to stat() anyway. */ 111 struct stat st;112 122 if (!stat(pszNativePath, &st)) 113 123 {
Note:
See TracChangeset
for help on using the changeset viewer.