| 915 | } |
| 916 | |
| 917 | static bool windows_complete_write(HANDLE file, const char *record, size_t length, |
| 918 | LARGE_INTEGER original_size) { |
| 919 | LARGE_INTEGER end = {.QuadPart = 0}; |
| 920 | if (!SetFilePointerEx(file, end, NULL, FILE_END)) { |
| 921 | return false; |
| 922 | } |
| 923 | size_t written = 0; |
| 924 | while (written < length) { |
| 925 | DWORD chunk = length - written > MAXDWORD ? MAXDWORD : (DWORD)(length - written); |
| 926 | DWORD count = 0; |
| 927 | if (!WriteFile(file, record + written, chunk, &count, NULL) || count == 0) { |
| 928 | LARGE_INTEGER rollback = original_size; |
| 929 | (void)SetFilePointerEx(file, rollback, NULL, FILE_BEGIN); |
| 930 | (void)SetEndOfFile(file); |
| 931 | return false; |
| 932 | } |
| 933 | written += count; |
| 934 | } |
| 935 | return FlushFileBuffers(file) != 0; |
| 936 | } |
| 937 | |
| 938 | static bool windows_log_append(const char *log_path, const char *record, size_t record_length, |
| 939 | size_t cap_bytes) { |
no outgoing calls
no test coverage detected