seems to be sort-of working!
This commit is contained in:
parent
eb49347abb
commit
feca00958c
@ -236,7 +236,9 @@ fi
|
||||
if test x"$vips_os_darwin" = x"yes"; then
|
||||
profile_dir="/Library/ColorSync/Profiles"
|
||||
elif test x"$vips_os_win32" = x"yes"; then
|
||||
profile_dir="C:\\Windows\\System32\\spool\\drivers\\color"
|
||||
# need double escapes since this will get pasted into a #define in a C
|
||||
# header
|
||||
profile_dir="C:\\\\Windows\\\\System32\\\\spool\\\\drivers\\\\color"
|
||||
else
|
||||
profile_dir="/usr/share/color/icc"
|
||||
fi
|
||||
|
@ -222,6 +222,9 @@ int vips_filename_suffix_match( const char *path, const char *suffixes[] );
|
||||
gint64 vips_file_length( int fd );
|
||||
int vips__write( int fd, const void *buf, size_t count );
|
||||
|
||||
int vips__open( const char *filename, int flags, ... );
|
||||
FILE *vips__fopen( const char *filename, const char *mode );
|
||||
|
||||
FILE *vips__file_open_read( const char *filename,
|
||||
const char *fallback_dir, gboolean text_mode );
|
||||
FILE *vips__file_open_write( const char *filename,
|
||||
|
@ -365,7 +365,7 @@ vips_tracked_open( const char *pathname, int flags, ... )
|
||||
mode = va_arg( ap, int );
|
||||
va_end( ap );
|
||||
|
||||
if( (fd = open( pathname, flags, mode )) == -1 )
|
||||
if( (fd = vips__open( pathname, flags, mode )) == -1 )
|
||||
return( -1 );
|
||||
|
||||
vips_tracked_init();
|
||||
|
@ -543,6 +543,74 @@ vips__write( int fd, const void *buf, size_t count )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* open() with a utf8 filename.
|
||||
*/
|
||||
int
|
||||
vips__open( const char *filename, int flags, ... )
|
||||
{
|
||||
int fd;
|
||||
mode_t mode;
|
||||
va_list ap;
|
||||
|
||||
va_start( ap, flags );
|
||||
mode = va_arg( ap, int );
|
||||
va_end( ap );
|
||||
|
||||
#ifdef OS_WIN32
|
||||
GError *error = NULL;
|
||||
wchar_t *path16;
|
||||
|
||||
if( !(path16 = (wchar_t *)
|
||||
g_utf8_to_utf16( filename, -1, NULL, NULL, &error )) ) {
|
||||
vips_g_error( &error );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
fd = _wopen( path16, flags, mode );
|
||||
|
||||
g_free( path16 );
|
||||
#else /*!OS_WIN32*/
|
||||
fd = open( filename, flags, mode );
|
||||
#endif
|
||||
|
||||
return( fd );
|
||||
}
|
||||
|
||||
/* fopen() with utf8 filename and mode.
|
||||
*/
|
||||
FILE *
|
||||
vips__fopen( const char *filename, const char *mode )
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
#ifdef OS_WIN32
|
||||
GError *error = NULL;
|
||||
wchar_t *path16, *mode16;
|
||||
|
||||
if( !(path16 = (wchar_t *)
|
||||
g_utf8_to_utf16( filename, -1, NULL, NULL, &error )) ) {
|
||||
vips_g_error( &error );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if( !(mode16 = (wchar_t *)
|
||||
g_utf8_to_utf16( mode, -1, NULL, NULL, &error )) ) {
|
||||
g_free( path16 );
|
||||
vips_g_error( &error );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
fp = _wfopen( path16, mode16 );
|
||||
|
||||
g_free( path16 );
|
||||
g_free( mode16 );
|
||||
#else /*!OS_WIN32*/
|
||||
fp = fopen( filename, mode );
|
||||
#endif
|
||||
|
||||
return( fp );
|
||||
}
|
||||
|
||||
/* Does a filename contain a directory separator?
|
||||
*/
|
||||
static gboolean
|
||||
@ -558,41 +626,6 @@ filename_hasdir( const char *filename )
|
||||
return( hasdir );
|
||||
}
|
||||
|
||||
/* fopen() with utf8 filename and mode.
|
||||
*/
|
||||
static FILE *
|
||||
vips__fopen( const char *filename, const char *mode )
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
#ifdef OS_WIN32
|
||||
GError *error = NULL;
|
||||
wchar_t *path16, *mode16;
|
||||
|
||||
if( !(path16 = (wchar_t *)
|
||||
g_utf8_to_utf16( filename, -1, NULL, NULL, &error )) ) {
|
||||
vips_g_error( error );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if( !(mode16 = (wchar_t *)
|
||||
g_utf8_to_utf16( mode, -1, NULL, NULL, &error )) ) {
|
||||
g_free( path16 );
|
||||
vips_g_error( error );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
fp = _wfopen( path16, mode16 );
|
||||
|
||||
g_free( path16 );
|
||||
g_free( mode16 );
|
||||
#else /*!OS_WIN32*/
|
||||
fp = fopen( filename, mode );
|
||||
#endif
|
||||
|
||||
return( fp );
|
||||
}
|
||||
|
||||
/* Open a file. We take an optional fallback dir as well and will try opening
|
||||
* there if opening directly fails.
|
||||
*
|
||||
@ -796,7 +829,7 @@ vips__get_bytes( const char *filename, unsigned char buf[], int len )
|
||||
* so no hasty messages. And the file might be truncated, so no error
|
||||
* on read either.
|
||||
*/
|
||||
if( (fd = open( name, MODE_READONLY )) == -1 )
|
||||
if( (fd = vips__open( name, MODE_READONLY )) == -1 )
|
||||
return( 0 );
|
||||
if( read( fd, buf, len ) != len ) {
|
||||
close( fd );
|
||||
@ -1070,7 +1103,7 @@ vips_existsf( const char *name, ... )
|
||||
path = g_strdup_vprintf( name, ap );
|
||||
va_end( ap );
|
||||
|
||||
result = access( path, R_OK );
|
||||
result = g_access( path, R_OK );
|
||||
|
||||
g_free( path );
|
||||
|
||||
|
@ -684,7 +684,6 @@ main( int argc, char **argv )
|
||||
* the args.
|
||||
*/
|
||||
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
|
||||
printf( "using g_win32_get_command_line()\n" );
|
||||
argv = g_win32_get_command_line();
|
||||
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user