Changeset 66591 in vbox for trunk/src/VBox/Runtime/common/misc
- Timestamp:
- Apr 17, 2017 3:08:21 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114618
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/RTFileModeToFlags.cpp
r62559 r66591 268 268 269 269 /* Create a new file, always, overwrite an existing file. */ 270 if (!RTStrCmp(pszCur, "ca")) 270 if ( !RTStrCmp(pszCur, "ca") 271 || !RTStrCmp(pszCur, "create-replace")) 271 272 fMode |= RTFILE_O_CREATE_REPLACE; 272 273 /* Create a new file if it does not exist, fail if exist. */ 273 else if (!RTStrCmp(pszCur, "ce")) 274 else if ( !RTStrCmp(pszCur, "ce") 275 || !RTStrCmp(pszCur, "create")) 274 276 fMode |= RTFILE_O_CREATE; 275 277 /* Open existing file, create file if does not exist. */ 276 else if (!RTStrCmp(pszCur, "oc")) 278 else if ( !RTStrCmp(pszCur, "oc") 279 || !RTStrCmp(pszCur, "open-create")) 277 280 fMode |= RTFILE_O_OPEN_CREATE; 278 281 /* Open existing file and place the file pointer at 279 282 * the end of the file, if opened with write access. 280 283 * Create the file if does not exist. */ 281 else if (!RTStrCmp(pszCur, "oa")) 284 else if ( !RTStrCmp(pszCur, "oa") 285 || !RTStrCmp(pszCur, "open-append")) 282 286 fMode |= RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND; 283 287 /* Open existing, fail if does not exist. */ 284 else if (!RTStrCmp(pszCur, "oe")) 288 else if ( !RTStrCmp(pszCur, "oe") 289 || !RTStrCmp(pszCur, "open")) 285 290 fMode |= RTFILE_O_OPEN; 286 291 /* Open and truncate existing, fail of not exist. */ 287 else if (!RTStrCmp(pszCur, "ot")) 292 else if ( !RTStrCmp(pszCur, "ot") 293 || !RTStrCmp(pszCur, "open-truncate")) 288 294 fMode |= RTFILE_O_OPEN | RTFILE_O_TRUNCATE; 289 295 else … … 294 300 return VERR_INVALID_PARAMETER; 295 301 296 /** @todo Handle sharing mode. */ 297 fMode |= RTFILE_O_DENY_NONE; 302 /* 303 * Sharing mode. 304 */ 305 if (!pszSharing || !*pszSharing) 306 fMode |= RTFILE_O_DENY_NONE; 307 else 308 { 309 do 310 { 311 if (pszSharing[0] == 'n') 312 { 313 if (pszSharing[1] == 'r') /* nr (no other readers) */ 314 { 315 if (pszSharing[2] == 'w') /* nrw (no other readers or writers) */ 316 { 317 fMode |= RTFILE_O_DENY_READWRITE; 318 pszSharing += 3; 319 } 320 else 321 { 322 fMode |= RTFILE_O_DENY_READ; 323 pszSharing += 2; 324 } 325 } 326 else if (pszSharing[1] == 'w') /* nw (no other writers) */ 327 { 328 fMode |= RTFILE_O_DENY_WRITE; 329 pszSharing += 2; 330 } 331 else 332 return VERR_INVALID_PARAMETER; 333 } 334 else if (pszSharing[0] == 'd') /* d (don't deny delete) */ 335 { 336 fMode |= RTFILE_O_DENY_WRITE; 337 pszSharing++; 338 } 339 else 340 return VERR_INVALID_PARAMETER; 341 } while (*pszSharing != '\0'); 342 } 298 343 299 344 /* Return. */
Note:
See TracChangeset
for help on using the changeset viewer.