17 #include "osdep/glob.h"
26 int mf_w
= 0; //352; // let codecs to detect it
29 char * mf_type
= NULL
; //"jpg";
31 mf_t
* open_mf(char * filename
){
32 #if defined(HAVE_GLOB) || defined(__MINGW32__)
41 mf
=calloc( 1,sizeof( mf_t
) );
43 if( filename
[0] == '@' )
45 FILE *lst_f
=fopen(filename
+ 1,"r");
49 while ( fgets( fname
,255,lst_f
) )
51 /* remove spaces from end of fname */
52 char *t
=fname
+ strlen( fname
) - 1;
53 while ( t
> fname
&& isspace( *t
) ) *(t
--)=0;
54 if ( stat( fname
,&fs
) )
56 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
60 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
61 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
67 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
70 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] %s is not indirect filelist\n",filename
+1 );
73 if( strchr( filename
,',') )
75 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] filelist: %s\n",filename
);
77 while ( ( fname
=strsep( &filename
,"," ) ) )
79 if ( stat( fname
,&fs
) )
81 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
85 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
86 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
87 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
91 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
96 fname
=malloc( strlen( filename
) + 32 );
98 if ( !strchr( filename
,'%' ) )
100 strcpy( fname
,filename
);
101 if ( !strchr( filename
,'*' ) ) strcat( fname
,"*" );
103 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] search expr: %s\n",fname
);
105 if ( glob( fname
,0,NULL
,&gg
) )
106 { free( mf
); free( fname
); return NULL
; }
108 mf
->nr_of_files
=gg
.gl_pathc
;
109 mf
->names
=calloc( gg
.gl_pathc
, sizeof( char* ) );
111 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d (%d)\n",mf
->nr_of_files
, gg
.gl_pathc
* sizeof( char* ) );
113 for( i
=0;i
< gg
.gl_pathc
;i
++ )
115 stat( gg
.gl_pathv
[i
],&fs
);
116 if( S_ISDIR( fs
.st_mode
) ) continue;
117 mf
->names
[i
]=strdup( gg
.gl_pathv
[i
] );
118 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] );
124 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] search expr: %s\n",filename
);
126 while ( error_count
< 5 )
128 sprintf( fname
,filename
,count
++ );
129 if ( stat( fname
,&fs
) )
132 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
136 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
137 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
138 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
143 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
149 mp_msg(MSGT_STREAM
,MSGL_FATAL
,"[mf] mf support is disabled on your os\n");