44#ifdef KINC_IMPLEMENTATION_IO
45#define KINC_IMPLEMENTATION
48#ifdef KINC_IMPLEMENTATION
50#if !defined(KINC_CONSOLE)
54#undef KINC_IMPLEMENTATION
58#define KINC_IMPLEMENTATION
63#if defined(KINC_WINDOWS)
64#include <kinc/backend/MiniWindows.h>
67#if defined(KINC_PS4) || defined(KINC_SWITCH)
69bool mountSaveData(
bool);
70void unmountSaveData();
75 writer->mounted =
false;
77 if (!mountSaveData(
true)) {
80 writer->mounted =
true;
83 strcpy(path, kinc_internal_save_path());
84 strcat(path, filepath);
87 wchar_t wpath[MAX_PATH];
88 MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, MAX_PATH);
89 writer->file = CreateFileW(wpath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
91 writer->file = fopen(path,
"wb");
93 if (writer->file == NULL) {
94 kinc_log(KINC_LOG_LEVEL_WARNING,
"Could not open file %s.", filepath);
101 if (writer->file != NULL) {
103 CloseHandle(writer->file);
105 fclose((FILE *)writer->file);
110 if (writer->mounted) {
111 writer->mounted =
false;
120 WriteFile(writer->file, data, (DWORD)size, &written, NULL);
122 fwrite(data, 1, size, (FILE *)writer->file);
Contains functionality to stop the program in case of an error and create a user-visible error messag...
Provides an API very similar to fwrite and friends but uses a directory that can actually used for pe...
KINC_FUNC bool kinc_file_writer_open(kinc_file_writer_t *writer, const char *filepath)
Opens a file for writing.
KINC_FUNC void kinc_file_writer_write(kinc_file_writer_t *writer, void *data, int size)
Writes data to a file starting from the current writing-position and increases the writing-position a...
KINC_FUNC void kinc_file_writer_close(kinc_file_writer_t *writer)
Closes a file.
Provides basic functionality that's used all over the place. There's usually no need to manually incl...
Contains basic logging functionality.
KINC_FUNC void kinc_log(kinc_log_level_t log_level, const char *format,...)
Logging function similar to printf including some system-specific bonuses.
Definition filewriter.h:16
Provides basic system and application-management functionality which doesn't fit anywhere else.