diff options
author | jstebbins <[email protected]> | 2009-11-25 21:14:44 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-11-25 21:14:44 +0000 |
commit | 009238a822971a933d0b7642fd04c15bf8e404a2 (patch) | |
tree | 0979d88ba5116f4ad7e41f55bc7f93a1a82040b9 /libhb/common.c | |
parent | 08483929dd5352012eb8b1f1143f138e3d5f19f0 (diff) |
batch file scanning and scan cancel
When a directory is specified as the source, first we attempt to open as a dvd,
then if that fails, we attempt to open each file in the directory as a stream
source. Since opening a large directory of files can take a really long time,
you can also now cancel a scan.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2980 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/common.c')
-rw-r--r-- | libhb/common.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/libhb/common.c b/libhb/common.c index 357625528..ce983987f 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -714,7 +714,7 @@ void hb_register_error_handler( hb_error_handler_t * handler ) ********************************************************************** * *********************************************************************/ -hb_title_t * hb_title_init( char * dvd, int index ) +hb_title_t * hb_title_init( char * path, int index ) { hb_title_t * t; @@ -724,7 +724,7 @@ hb_title_t * hb_title_init( char * dvd, int index ) t->list_audio = hb_list_init(); t->list_chapter = hb_list_init(); t->list_subtitle = hb_list_init(); - strcat( t->dvd, dvd ); + strcat( t->path, path ); // default to decoding mpeg2 t->video_id = 0xE0; t->video_codec = WORK_DECMPEG2; @@ -973,3 +973,45 @@ int hb_srt_add( const hb_job_t * job, } return retval; } + +char * hb_strdup_printf( char * fmt, ... ) +{ + int len; + va_list ap; + int size = 256; + char * str; + char * tmp; + + str = malloc( size ); + if ( str == NULL ) + return NULL; + + while (1) + { + /* Try to print in the allocated space. */ + va_start( ap, fmt ); + len = vsnprintf( str, size, fmt, ap ); + va_end( ap ); + + /* If that worked, return the string. */ + if ( len > -1 && len < size ) + { + return str; + } + + /* Else try again with more space. */ + if ( len > -1 ) /* glibc 2.1 */ + size = len + 1; /* precisely what is needed */ + else /* glibc 2.0 */ + size *= 2; /* twice the old size */ + tmp = realloc( str, size ); + if ( tmp == NULL ) + { + free( str ); + return NULL; + } + else + str = tmp; + } +} + |