| 379 | } |
| 380 | |
| 381 | bool |
| 382 | MemoryFile::flush(FlushTypeEnum type, void* data, std::size_t size) |
| 383 | { |
| 384 | void* ptr = data ? data : _imp->data; |
| 385 | std::size_t n = data ? size : _imp->size; |
| 386 | #if defined(__NATRON_UNIX__) |
| 387 | switch (type) { |
| 388 | case eFlushTypeAsync: |
| 389 | return ::msync(ptr, n, MS_ASYNC) == 0; |
| 390 | case eFlushTypeSync: |
| 391 | return ::msync(ptr, n, MS_SYNC) == 0; |
| 392 | case eFlushTypeInvalidate: |
| 393 | return ::msync(ptr, n, MS_INVALIDATE) == 0; |
| 394 | default: |
| 395 | break; |
| 396 | } |
| 397 | #elif defined(__NATRON_WIN32__) |
| 398 | switch (type) { |
| 399 | case eFlushTypeSync: { |
| 400 | bool ret = (bool)::FlushViewOfFile(ptr, n) != 0; |
| 401 | if (ret) { |
| 402 | ret = (bool)::FlushFileBuffers(_imp->file_handle); |
| 403 | } |
| 404 | return ret; |
| 405 | } break; |
| 406 | case eFlushTypeAsync: |
| 407 | return (bool)::FlushViewOfFile(ptr, n) != 0; |
| 408 | case eFlushTypeInvalidate: |
| 409 | return true; |
| 410 | break; |
| 411 | } |
| 412 | #endif |
| 413 | return false; |
| 414 | } |
| 415 | |
| 416 | MemoryFile::~MemoryFile() |
| 417 | { |
no outgoing calls
no test coverage detected