mixer: fix lowering hw volume while muted
[mplayer.git] / osdep / glob-win.c
blob25e63e05d1939e19e3bebf0670bff08c0b6ba06d
1 /*
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.
19 #include <sys/types.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
24 #include "config.h"
26 #include <windows.h>
27 #include "glob.h"
29 int glob(const char *pattern, int flags,
30 int (*errfunc)(const char *epath, int eerrno), glob_t *pglob)
32 HANDLE searchhndl;
33 WIN32_FIND_DATA found_file;
34 if(errfunc)printf("glob():ERROR:Sorry errfunc not supported by this implementation\n");
35 if(flags)printf("glob():ERROR:Sorry no flags supported by this globimplementation\n");
36 //printf("PATTERN \"%s\"\n",pattern);
37 pglob->gl_pathc = 0;
38 searchhndl = FindFirstFile( pattern,&found_file);
39 if(searchhndl == INVALID_HANDLE_VALUE)
41 if(GetLastError() == ERROR_FILE_NOT_FOUND)
43 pglob->gl_pathc = 0;
44 //printf("could not find a file matching your search criteria\n");
45 return 1;
47 else
49 //printf("glob():ERROR:FindFirstFile: %i\n",GetLastError());
50 return 1;
53 pglob->gl_pathv = malloc(sizeof(char*));
54 pglob->gl_pathv[0] = strdup(found_file.cFileName);
55 pglob->gl_pathc++;
56 while(1)
58 if(!FindNextFile(searchhndl,&found_file))
60 if(GetLastError()==ERROR_NO_MORE_FILES)
62 //printf("glob(): no more files found\n");
63 break;
65 else
67 //printf("glob():ERROR:FindNextFile:%i\n",GetLastError());
68 return 1;
71 else
73 //printf("glob: found file %s\n",found_file.cFileName);
74 pglob->gl_pathc++;
75 pglob->gl_pathv = realloc(pglob->gl_pathv,pglob->gl_pathc * sizeof(char*));
76 pglob->gl_pathv[pglob->gl_pathc-1] = strdup(found_file.cFileName);
79 FindClose(searchhndl);
80 return 0;
83 void globfree(glob_t *pglob)
85 int i;
86 for(i=0; i <pglob->gl_pathc ;i++)
88 free(pglob->gl_pathv[i]);
90 free(pglob->gl_pathv);
93 #if 0
94 int main(void){
95 glob_t gg;
96 printf("globtest\n");
97 glob( "*.jpeg",0,NULL,&gg );
99 int i;
100 for(i=0;i<gg.gl_pathc;i++)printf("GLOBED:%i %s\n",i,gg.gl_pathv[i]);
102 globfree(&gg);
104 return 0;
106 #endif