start adding better filename handling
This commit is contained in:
parent
da546ec429
commit
eb49347abb
12
TODO
12
TODO
@ -1,3 +1,15 @@
|
||||
- on win see:
|
||||
|
||||
vips2tiff:389 unknown control sequence
|
||||
\W \S \s \d \c
|
||||
|
||||
if( !(buffer = vips__file_read_name( profile, VIPS_ICC_DIR, &length )) )
|
||||
|
||||
config.h:#define VIPS_ICC_DIR "C:\Windows\System32\spool\drivers\color"
|
||||
|
||||
hehe argh
|
||||
|
||||
|
||||
- add APPROX convsep test?
|
||||
|
||||
- add more webp tests to py suite
|
||||
|
19
configure.ac
19
configure.ac
@ -383,6 +383,17 @@ PKG_CHECK_MODULES(TYPE_INIT, glib-2.0 < 2.36,
|
||||
]
|
||||
)
|
||||
|
||||
# with 2.40 we have g_win32_get_command_line() on win
|
||||
PKG_CHECK_MODULES(TYPE_INIT, glib-2.0 >= 2.40,
|
||||
[if test x"$vips_os_win32" = x"yes"; then
|
||||
AC_DEFINE(HAVE_G_WIN32_GET_COMMAND_LINE,1,[define if your glib has g_win32_get_command_line().])
|
||||
have_g_win32_get_command_line=yes
|
||||
fi
|
||||
],
|
||||
[:
|
||||
]
|
||||
)
|
||||
|
||||
# check for gtk-doc
|
||||
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
|
||||
|
||||
@ -1136,3 +1147,11 @@ You may need to copy this file, for example:
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if test x"$vips_os_win32" = x"yes"; then
|
||||
if test x"$have_g_win32_get_command_line" != x"yes"; then
|
||||
AC_MSG_RESULT([dnl
|
||||
Your glib is too old, vips will not support unicode command-line arguments.
|
||||
])
|
||||
fi
|
||||
fi
|
||||
|
@ -558,6 +558,41 @@ 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.
|
||||
*
|
||||
@ -581,7 +616,7 @@ vips__file_open_read( const char *filename, const char *fallback_dir,
|
||||
mode = "r";
|
||||
#endif /*BINARY_OPEN*/
|
||||
|
||||
if( (fp = fopen( filename, mode )) )
|
||||
if( (fp = vips__fopen( filename, mode )) )
|
||||
return( fp );
|
||||
|
||||
if( fallback_dir &&
|
||||
@ -589,7 +624,7 @@ vips__file_open_read( const char *filename, const char *fallback_dir,
|
||||
char *path;
|
||||
|
||||
path = g_build_filename( fallback_dir, filename, NULL );
|
||||
fp = fopen( path, mode );
|
||||
fp = vips__fopen( path, mode );
|
||||
g_free( path );
|
||||
|
||||
if( fp )
|
||||
@ -617,7 +652,7 @@ vips__file_open_write( const char *filename, gboolean text_mode )
|
||||
mode = "w";
|
||||
#endif /*BINARY_OPEN*/
|
||||
|
||||
if( !(fp = fopen( filename, mode )) ) {
|
||||
if( !(fp = vips__fopen( filename, mode )) ) {
|
||||
vips_error_system( errno, "vips__file_open_write",
|
||||
_( "unable to open file \"%s\" for writing" ),
|
||||
filename );
|
||||
|
@ -680,6 +680,14 @@ main( int argc, char **argv )
|
||||
textdomain( GETTEXT_PACKAGE );
|
||||
setlocale( LC_ALL, "" );
|
||||
|
||||
/* On Windows, argv is ascii-only .. use this to get a utf-8 version of
|
||||
* 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*/
|
||||
|
||||
context = g_option_context_new( _( "- thumbnail generator" ) );
|
||||
|
||||
main_group = g_option_group_new( NULL, NULL, NULL, NULL, NULL );
|
||||
@ -738,6 +746,12 @@ main( int argc, char **argv )
|
||||
g_object_unref( process );
|
||||
}
|
||||
|
||||
/* We don't free this on error exit, sadly.
|
||||
*/
|
||||
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
|
||||
g_strfreev( argv );
|
||||
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
|
||||
|
||||
vips_shutdown();
|
||||
|
||||
return( result );
|
||||
|
Loading…
Reference in New Issue
Block a user