Added debug printing for os stream.

This commit is contained in:
Nathan Moinvaziri 2018-11-07 20:24:59 -08:00
parent 65dbda889d
commit 23342c44d4

View File

@ -15,6 +15,7 @@
*/
#include <stdlib.h>
#include <inttypes.h>
#include <windows.h>
@ -67,6 +68,14 @@ typedef struct mz_stream_win32_s
/***************************************************************************/
#if 0
# define mz_stream_os_print printf
#else
# define mz_stream_os_print(fmt,...)
#endif
/***************************************************************************/
int32_t mz_stream_os_open(void *stream, const char *path, int32_t mode)
{
mz_stream_win32 *win32 = (mz_stream_win32 *)stream;
@ -104,6 +113,8 @@ int32_t mz_stream_os_open(void *stream, const char *path, int32_t mode)
return MZ_PARAM_ERROR;
}
mz_stream_os_print("Win32 - Open - %s (mode %"PRId32")\n", path);
path_wide = mz_os_unicode_string_create(path, MZ_ENCODING_UTF8);
if (path_wide == NULL)
return MZ_PARAM_ERROR;
@ -153,6 +164,8 @@ int32_t mz_stream_os_read(void *stream, void *buf, int32_t size)
win32->error = 0;
}
mz_stream_os_print("Win32 - Read - %"PRId32"\n", read);
return read;
}
@ -171,6 +184,8 @@ int32_t mz_stream_os_write(void *stream, const void *buf, int32_t size)
win32->error = 0;
}
mz_stream_os_print("Win32 - Write - %"PRId32"\n", written);
return written;
}
@ -212,6 +227,8 @@ int64_t mz_stream_os_tell(void *stream)
if (mz_stream_os_seekinternal(win32->handle, large_pos, &large_pos, FILE_CURRENT) != MZ_OK)
win32->error = GetLastError();
mz_stream_os_print("Win32 - Tell - %"PRId64"\n", large_pos.QuadPart);
return large_pos.QuadPart;
}
@ -241,6 +258,8 @@ int32_t mz_stream_os_seek(void *stream, int64_t offset, int32_t origin)
return MZ_SEEK_ERROR;
}
mz_stream_os_print("Win32 - Seek - %"PRId64" (origin %"PRId32")\n", offset, origin);
large_pos.QuadPart = offset;
err = mz_stream_os_seekinternal(win32->handle, large_pos, NULL, move_method);
@ -259,6 +278,7 @@ int32_t mz_stream_os_close(void *stream)
if (win32->handle != NULL)
CloseHandle(win32->handle);
mz_stream_os_print("Win32 - Close\n");
win32->handle = NULL;
return MZ_OK;
}