31
31
#include "config.h"
36
36
#include "osdep/glob.h"
39
#include "mpvcore/mp_msg.h"
40
#include "common/msg.h"
40
41
#include "stream/stream.h"
41
#include "mpvcore/path.h"
42
#include "options/path.h"
46
char * mf_type = NULL; //"jpg";
48
mf_t* open_mf_pattern(char * filename)
47
char *mf_type = NULL; //"jpg";
49
static void mf_add(mf_t *mf, const char *fname)
51
char *entry = talloc_strdup(mf, fname);
52
MP_TARRAY_APPEND(mf, mf->names, mf->nr_of_files, entry);
55
mf_t *open_mf_pattern(void *talloc_ctx, struct mp_log *log, char *filename)
50
57
#if defined(HAVE_GLOB) || defined(__MINGW32__)
58
mf=calloc( 1,sizeof( mf_t ) );
60
if( filename[0] == '@' )
62
FILE *lst_f=fopen(filename + 1,"r");
65
fname=malloc(MP_PATH_MAX);
66
while ( fgets( fname,MP_PATH_MAX,lst_f ) )
68
/* remove spaces from end of fname */
69
char *t=fname + strlen( fname ) - 1;
70
while ( t > fname && isspace( *t ) ) *(t--)=0;
71
if ( !mp_path_exists( fname ) )
73
mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname );
77
mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) );
78
mf->names[mf->nr_of_files]=strdup( fname );
84
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files );
87
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] %s is not indirect filelist\n",filename+1 );
90
if( strchr( filename,',') )
92
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] filelist: %s\n",filename );
93
bstr bfilename = bstr0(filename);
98
bstr_split_tok(bfilename, ",", &bfname, &bfilename);
99
char *fname2 = bstrdup0(NULL, bfname);
101
if ( !mp_path_exists( fname2 ) )
103
mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname2 );
107
mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) );
108
mf->names[mf->nr_of_files] = strdup(fname2);
109
// mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
114
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files );
119
fname=malloc( strlen( filename ) + 32 );
121
if ( !strchr( filename,'%' ) )
123
strcpy( fname,filename );
124
if ( !strchr( filename,'*' ) ) strcat( fname,"*" );
126
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname );
128
if ( glob( fname,0,NULL,&gg ) )
129
{ free( mf ); free( fname ); return NULL; }
132
mf->names=calloc( gg.gl_pathc, sizeof( char* ) );
134
for( i=0;i < gg.gl_pathc;i++ )
136
if (mp_path_isdir(gg.gl_pathv[i]))
138
mf->names[mf->nr_of_files]=strdup( gg.gl_pathv[i] );
140
// mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] );
142
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files);
147
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename );
149
while ( error_count < 5 )
151
sprintf( fname,filename,count++ );
152
if ( !mp_path_exists( fname ) )
155
mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname );
159
mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) );
160
mf->names[mf->nr_of_files]=strdup( fname );
161
// mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
166
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files );
61
mf_t *mf = talloc_zero(talloc_ctx, mf_t);
64
if (filename[0] == '@') {
65
FILE *lst_f = fopen(filename + 1, "r");
67
char *fname = talloc_size(mf, MP_PATH_MAX);
68
while (fgets(fname, MP_PATH_MAX, lst_f)) {
69
/* remove spaces from end of fname */
70
char *t = fname + strlen(fname) - 1;
71
while (t > fname && isspace(*t))
73
if (!mp_path_exists(fname)) {
74
mp_verbose(log, "file not found: '%s'\n", fname);
81
mp_info(log, "number of files: %d\n", mf->nr_of_files);
84
mp_info(log, "%s is not indirect filelist\n", filename + 1);
87
if (strchr(filename, ',')) {
88
mp_info(log, "filelist: %s\n", filename);
89
bstr bfilename = bstr0(filename);
91
while (bfilename.len) {
93
bstr_split_tok(bfilename, ",", &bfname, &bfilename);
94
char *fname2 = bstrdup0(mf, bfname);
96
if (!mp_path_exists(fname2))
97
mp_verbose(log, "file not found: '%s'\n", fname2);
103
mp_info(log, "number of files: %d\n", mf->nr_of_files);
108
char *fname = talloc_size(mf, strlen(filename) + 32);
110
if (!strchr(filename, '%')) {
111
strcpy(fname, filename);
112
if (!strchr(filename, '*'))
115
mp_info(log, "search expr: %s\n", fname);
118
if (glob(fname, 0, NULL, &gg)) {
123
for (int i = 0; i < gg.gl_pathc; i++) {
124
if (mp_path_isdir(gg.gl_pathv[i]))
126
mf_add(mf, gg.gl_pathv[i]);
128
mp_info(log, "number of files: %d\n", mf->nr_of_files);
133
mp_info(log, "search expr: %s\n", filename);
135
while (error_count < 5) {
136
sprintf(fname, filename, count++);
137
if (!mp_path_exists(fname)) {
139
mp_verbose(log, "file not found: '%s'\n", fname);
145
mp_info(log, "number of files: %d\n", mf->nr_of_files);
172
mp_msg(MSGT_STREAM,MSGL_FATAL,"[mf] mf support is disabled on your os\n");
150
mp_fatal(log, "mf support is disabled on your os\n");
177
mf_t* open_mf_single(char * filename)
155
mf_t *open_mf_single(void *talloc_ctx, struct mp_log *log, char *filename)
179
mf_t *mf = calloc(1, sizeof(mf_t));
181
mf->names = calloc(1, sizeof(char *));
182
mf->names[0] = strdup(filename);
157
mf_t *mf = talloc_zero(talloc_ctx, mf_t);
159
mf_add(mf, filename);