1 2 3 4 5 6 7 8 9 10 11 12 | void saveFile(FileInfo *file, char *filename) { HANDLE fileHandle = CreateFileA(filename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); if(fileHandle != INVALID_HANDLE_VALUE) { DWORD bytesWritten; int error = WriteFile(fileHandle, (void *)file->contents, (DWORD)file->filesize, &bytesWritten, 0); CloseHandle(fileHandle); } } |
So WriteFile doesn't return any errors, and it have a fileHandle, and GetLastError returns that the file already exists. bytesWritten is always exactly how many bytes I want to be written (the filesize).
The only thing I can think of that might have changed inbetween those times is that I add a null at the end of the file, but I don't include it when saving the file. Would a null be preventing the WriteFile from completing it's task?