Changeset 33885 in vbox
- Timestamp:
- Nov 9, 2010 10:28:35 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 67533
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp
r33863 r33885 146 146 bool fVerbose = false; 147 147 148 char *pszDir = NULL; 149 RTFMODE fMode = 0; /** @todo Get standard mode from umask? */ 148 char szDir[RTPATH_MAX]; 149 RTFMODE newMode = 0; 150 RTFMODE fileMode = RTFS_UNIX_MASK | RTFS_TYPE_DIRECTORY; 150 151 151 152 while ( (ch = RTGetOpt(&GetState, &ValueUnion)) … … 160 161 161 162 case 'm': 162 /* Ignore by now. */ 163 rc = RTStrToUInt32Ex(ValueUnion.psz, NULL, 8 /* Base */, &newMode); 164 if (RT_FAILURE(rc)) /* Only octet based values supported right now! */ 165 VBoxServiceVerbose(0, "mkdir: Mode flag strings not implemented yet!\n"); 163 166 break; 164 167 … … 169 172 case VINF_GETOPT_NOT_OPTION: 170 173 { 171 pszDir = RTPathAbsDup(ValueUnion.psz);172 if ( !pszDir)173 rc = VERR_NO_MEMORY;174 rc = RTPathAbs(ValueUnion.psz, szDir, sizeof(szDir)); 175 if (RT_FAILURE(rc)) 176 VBoxServiceError("mkdir: Could not build absolute directory!\n"); 174 177 break; 175 178 } … … 182 185 if (RT_SUCCESS(rc)) 183 186 { 187 if (fMakeParentDirs || newMode) 188 { 189 #ifndef RT_OS_WINDOWS 190 mode_t umaskMode = umask(0); /* Get current umask. */ 191 if (newMode) 192 { 193 fileMode |= newMode; 194 } 195 else 196 fileMode |= S_IRWXUGO & ~umaskMode; 197 #endif 198 } 199 184 200 rc = fMakeParentDirs ? 185 RTDirCreateFullPath( pszDir, fMode)186 : RTDirCreate( pszDir, fMode);201 RTDirCreateFullPath(szDir, fileMode) 202 : RTDirCreate(szDir, fileMode); 187 203 188 204 if (RT_SUCCESS(rc) && fVerbose) 189 VBoxServiceVerbose(0, "mkdir: Created directory '%s' \n", pszDir);205 VBoxServiceVerbose(0, "mkdir: Created directory '%s', mode 0x%RTfmode\n", szDir, fileMode); 190 206 else if (RT_FAILURE(rc)) /** @todo Add a switch with more helpful error texts! */ 191 VBoxServiceError("mkdir: Could not create directory, rc=%Rrc\n", rc); 207 { 208 PCRTSTATUSMSG pMsg = RTErrGet(rc); 209 if (pMsg) 210 VBoxServiceError("mkdir: Could not create directory: %s\n", pMsg->pszMsgFull); 211 else 212 VBoxServiceError("mkdir: Could not create directory, rc=%Rrc\n", rc); 213 } 214 192 215 } 193 else 216 else if (fVerbose) 194 217 VBoxServiceError("mkdir: Failed with rc=%Rrc\n", rc); 195 if (pszDir)196 RTStrFree(pszDir);197 218 return rc; 198 219 }
Note:
See TracChangeset
for help on using the changeset viewer.