MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / File_Write

Function File_Write

src/file.c:765–780  ·  view source on GitHub ↗

* Write bytes from a buffer to a file. * * @param index The index given by File_Open() of the file. * @param buffer The buffer to write from. * @param length The amount of bytes to write. * @return The amount of bytes truly written, or 0 if there was a failure. */

Source from the content-addressed store, hash-verified

763 * @return The amount of bytes truly written, or 0 if there was a failure.
764 */
765uint32 File_Write(uint8 index, void *buffer, uint32 length)
766{
767 if (index >= FILE_MAX) return 0;
768 if (s_file[index].fp == NULL) return 0;
769
770 if (fwrite(buffer, length, 1, s_file[index].fp) != 1) {
771 Error("Write error\n");
772 File_Close(index);
773
774 length = 0;
775 }
776
777 s_file[index].position += length;
778 if (s_file[index].position > s_file[index].size) s_file[index].size = s_file[index].position;
779 return length;
780}
781
782/**
783 * Write a 16bit unsigned to the file (written on disk in Little endian)

Callers 3

File_Write_LE16Function · 0.85
GUI_HallOfFame_ShowFunction · 0.85
Input_HandleInputFunction · 0.85

Calls 2

File_CloseFunction · 0.85
ErrorFunction · 0.50

Tested by

no test coverage detected