Huge Windows utf8 I/O patch.

Patch from Janne Hyvärinen <cse@sci.fi>.
This commit is contained in:
Erik de Castro Lopo
2013-03-21 19:18:49 +11:00
parent 9b8fdafe3a
commit 5705b4d7b2
68 changed files with 3200 additions and 299 deletions

View File

@@ -141,6 +141,44 @@
# endif
#endif /* defined _MSC_VER */
#ifdef FLAC__STRINGS_IN_UTF8 /* all char* strings are in UTF-8 format. Added to support Unicode files on Windows */
#include "share/utf8_io.h"
#define flac_printf printf_utf8
#define flac_fprintf fprintf_utf8
#define flac_vfprintf vfprintf_utf8
#define flac_fopen fopen_utf8
#define flac_stat _stat64_utf8
#define flac_chmod chmod_utf8
#define flac_utime utime_utf8
#define flac_unlink unlink_utf8
#define flac_rename rename_utf8
#else
#define flac_printf printf
#define flac_fprintf fprintf
#define flac_vfprintf vfprintf
#define flac_fopen fopen
#ifdef _WIN32
#define flac_stat _stat64
#else
#define flac_stat stat
#endif
#define flac_chmod chmod
#define flac_utime utime
#define flac_unlink unlink
#define flac_rename rename
#endif
#ifdef _WIN32
#define _flac_stat _stat64 /* stat struct */
#define flac_fstat _fstat64
#else
#define _flac_stat stat /* stat struct */
#define flac_fstat fstat
#endif
/* FLAC needs to compile and work correctly on systems with a norrmal ISO C99
* snprintf as well as Microsoft Visual Studio which has an non-standards

34
include/share/utf8_io.h Normal file
View File

@@ -0,0 +1,34 @@
#ifdef FLAC__STRINGS_IN_UTF8
#ifndef flac__utf8_io_h
#define flac__utf8_io_h
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <sys/stat.h>
#include <stdarg.h>
int get_utf8_argv(int *argc, char ***argv);
int printf_utf8(const char *format, ...);
int fprintf_utf8(FILE *stream, const char *format, ...);
int vfprintf_utf8(FILE *stream, const char *format, va_list argptr);
FILE *fopen_utf8(const char *filename, const char *mode);
int stat_utf8(const char *path, struct stat *buffer);
int _stat64_utf8(const char *path, struct _stat64 *buffer);
int chmod_utf8(const char *filename, int pmode);
int utime_utf8(const char *filename, struct utimbuf *times);
int unlink_utf8(const char *filename);
int rename_utf8(const char *oldname, const char *newname);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
#endif