-
Notifications
You must be signed in to change notification settings - Fork 1
/
ufile.cc
41 lines (33 loc) · 869 Bytes
/
ufile.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifdef __WIN32
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <windows.h>
#include "ufile.hh"
FILE *gd_fopen( const char *filename, const char *mode)
{
wchar_t wname[16384], wmode[32];
if( MultiByteToWideChar( CP_UTF8, 0, filename, -1, wname, 16384 ) == 0 )
return NULL;
if( MultiByteToWideChar( CP_UTF8, 0, mode, -1, wmode, 32 ) == 0 )
return NULL;
return _wfopen( wname, wmode );
}
int gd_open( const char *filename)
{
wchar_t wname[16384];
if( MultiByteToWideChar( CP_UTF8, 0, filename, -1, wname, 16384 ) == 0 )
return -1;
return _wopen( wname, _O_RDONLY | _O_BINARY );
}
gzFile gd_gzopen( const char *filename )
{
int id = gd_open( filename );
if( id == -1 )
return NULL;
gzFile f = gzdopen( id, "rb");
if( f == NULL )
_close( id );
return f;
}
#endif