2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <sys/types.h>
35 #include "osdep/glob.h"
37 #include "osdep/strsep.h"
40 #include "stream/stream.h"
44 int mf_w
= 0; //352; // let codecs to detect it
47 char * mf_type
= NULL
; //"jpg";
49 mf_t
* open_mf(char * filename
){
50 #if defined(HAVE_GLOB) || defined(__MINGW32__)
59 mf
=calloc( 1,sizeof( mf_t
) );
61 if( filename
[0] == '@' )
63 FILE *lst_f
=fopen(filename
+ 1,"r");
66 fname
=malloc(PATH_MAX
);
67 while ( fgets( fname
,PATH_MAX
,lst_f
) )
69 /* remove spaces from end of fname */
70 char *t
=fname
+ strlen( fname
) - 1;
71 while ( t
> fname
&& isspace( *t
) ) *(t
--)=0;
72 if ( stat( fname
,&fs
) )
74 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
78 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
79 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
85 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
88 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] %s is not indirect filelist\n",filename
+1 );
91 if( strchr( filename
,',') )
93 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] filelist: %s\n",filename
);
95 while ( ( fname
=strsep( &filename
,"," ) ) )
97 if ( stat( fname
,&fs
) )
99 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
103 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
104 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
105 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
109 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
114 fname
=malloc( strlen( filename
) + 32 );
116 if ( !strchr( filename
,'%' ) )
118 strcpy( fname
,filename
);
119 if ( !strchr( filename
,'*' ) ) strcat( fname
,"*" );
121 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] search expr: %s\n",fname
);
123 if ( glob( fname
,0,NULL
,&gg
) )
124 { free( mf
); free( fname
); return NULL
; }
126 mf
->nr_of_files
=gg
.gl_pathc
;
127 mf
->names
=calloc( gg
.gl_pathc
, sizeof( char* ) );
129 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d (%d)\n",mf
->nr_of_files
, gg
.gl_pathc
* sizeof( char* ) );
131 for( i
=0;i
< gg
.gl_pathc
;i
++ )
133 stat( gg
.gl_pathv
[i
],&fs
);
134 if( S_ISDIR( fs
.st_mode
) ) continue;
135 mf
->names
[i
]=strdup( gg
.gl_pathv
[i
] );
136 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] );
142 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] search expr: %s\n",filename
);
144 while ( error_count
< 5 )
146 sprintf( fname
,filename
,count
++ );
147 if ( stat( fname
,&fs
) )
150 mp_msg( MSGT_STREAM
,MSGL_V
,"[mf] file not found: '%s'\n",fname
);
154 mf
->names
=realloc( mf
->names
,( mf
->nr_of_files
+ 1 ) * sizeof( char* ) );
155 mf
->names
[mf
->nr_of_files
]=strdup( fname
);
156 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
161 mp_msg( MSGT_STREAM
,MSGL_INFO
,"[mf] number of files: %d\n",mf
->nr_of_files
);
167 mp_msg(MSGT_STREAM
,MSGL_FATAL
,"[mf] mf support is disabled on your os\n");