Whether using synchronous or asynchronous I/O if a call to WriteFile is unable to write the number of bytes specified because the disk is full then the write fails, 0 bytes are reported as written, and the last error code is set to 112 (There is not enough space on the disk).
WriteFile and partial writes
Is it possible for WriteFile() to perform a partial write? Let's say we want to write 100 bytes to a file and only 50 bytes can be written (for example, the disk is full). Would WriteFile() return success and *lpNumberOfBytesWritten would be 50? Would WriteFile() return error and *lpNumberOfBytesWritten would be 50?
When using asynchronous I/O (opening the file with FILE_FLAG_OVERLAPPED and passing a pointer to an overlapped struct in WriteFile()): can the data be partially written to disk (for example, 50 bytes can be immediately written to the file but not the remainder 50 bytes)? would WriteFile() return success and *lpNumberOfBytesWritten would be 50? would WriteFile() return error (ERROR_IO_PENDING) and *lpNumberOfBytesWritten would be 50?