| 322 | |
| 323 | |
| 324 | void PIO_force_write(jrd_file* file, const bool forceWrite, const bool notUseFSCache) |
| 325 | { |
| 326 | /************************************** |
| 327 | * |
| 328 | * P I O _ f o r c e _ w r i t e |
| 329 | * |
| 330 | ************************************** |
| 331 | * |
| 332 | * Functional description |
| 333 | * Set (or clear) force write, if possible, for the database. |
| 334 | * |
| 335 | **************************************/ |
| 336 | |
| 337 | const bool oldForce = (file->fil_flags & FIL_force_write) != 0; |
| 338 | const bool oldNotUseCache = (file->fil_flags & FIL_no_fs_cache) != 0; |
| 339 | |
| 340 | if (forceWrite != oldForce || notUseFSCache != oldNotUseCache) |
| 341 | { |
| 342 | const int force = forceWrite ? FILE_FLAG_WRITE_THROUGH : 0; |
| 343 | const int fsCache = notUseFSCache ? FILE_FLAG_NO_BUFFERING : 0; |
| 344 | const int writeMode = (file->fil_flags & FIL_readonly) ? 0 : GENERIC_WRITE; |
| 345 | const bool sharedMode = (file->fil_flags & FIL_sh_write); |
| 346 | |
| 347 | HANDLE& hFile = file->fil_desc; |
| 348 | maybeCloseFile(hFile); |
| 349 | hFile = CreateFile(file->fil_string, |
| 350 | GENERIC_READ | writeMode, |
| 351 | getShareFlags(sharedMode), |
| 352 | NULL, |
| 353 | OPEN_EXISTING, |
| 354 | FILE_ATTRIBUTE_NORMAL | force | fsCache | g_dwExtraFlags, |
| 355 | 0); |
| 356 | |
| 357 | if (hFile == INVALID_HANDLE_VALUE) |
| 358 | { |
| 359 | ERR_post(Arg::Gds(isc_io_error) << Arg::Str("CreateFile (force write)") << |
| 360 | Arg::Str(file->fil_string) << |
| 361 | Arg::Gds(isc_io_access_err) << Arg::Windows(GetLastError())); |
| 362 | } |
| 363 | |
| 364 | if (forceWrite) { |
| 365 | file->fil_flags |= FIL_force_write; |
| 366 | } |
| 367 | else { |
| 368 | file->fil_flags &= ~FIL_force_write; |
| 369 | } |
| 370 | if (notUseFSCache) { |
| 371 | file->fil_flags |= FIL_no_fs_cache; |
| 372 | } |
| 373 | else { |
| 374 | file->fil_flags &= ~FIL_no_fs_cache; |
| 375 | } |
| 376 | |
| 377 | SetFileCompletionNotificationModes(hFile, FILE_SKIP_SET_EVENT_ON_HANDLE); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 |
nothing calls this directly
no test coverage detected