Mercurial > mplayer.hg
comparison osdep/glob-win.c @ 34151:c7ff1a52e160
Use uncrustify on glob-win.c to fix the indentation mess in it.
author | reimar |
---|---|
date | Sun, 23 Oct 2011 11:51:44 +0000 |
parents | c70109fc98b2 |
children |
comparison
equal
deleted
inserted
replaced
34150:05c4e9ce128f | 34151:c7ff1a52e160 |
---|---|
25 | 25 |
26 #include <windows.h> | 26 #include <windows.h> |
27 #include "glob.h" | 27 #include "glob.h" |
28 | 28 |
29 int glob(const char *pattern, int flags, | 29 int glob(const char *pattern, int flags, |
30 int (*errfunc)(const char *epath, int eerrno), glob_t *pglob) | 30 int (*errfunc)(const char *epath, int eerrno), glob_t *pglob) |
31 { | 31 { |
32 HANDLE searchhndl; | 32 HANDLE searchhndl; |
33 WIN32_FIND_DATA found_file; | 33 WIN32_FIND_DATA found_file; |
34 if(errfunc)printf("glob():ERROR:Sorry errfunc not supported by this implementation\n"); | 34 if (errfunc) |
35 if(flags)printf("glob():ERROR:Sorry no flags supported by this globimplementation\n"); | 35 printf("glob():ERROR:Sorry errfunc not supported by this implementation\n"); |
36 //printf("PATTERN \"%s\"\n",pattern); | 36 if (flags) |
37 pglob->gl_pathc = 0; | 37 printf("glob():ERROR:Sorry no flags supported by this globimplementation\n"); |
38 searchhndl = FindFirstFile( pattern,&found_file); | 38 //printf("PATTERN \"%s\"\n",pattern); |
39 if(searchhndl == INVALID_HANDLE_VALUE) | 39 pglob->gl_pathc = 0; |
40 { | 40 searchhndl = FindFirstFile(pattern, &found_file); |
41 if(GetLastError() == ERROR_FILE_NOT_FOUND) | 41 if (searchhndl == INVALID_HANDLE_VALUE) { |
42 { | 42 if (GetLastError() == ERROR_FILE_NOT_FOUND) { |
43 pglob->gl_pathc = 0; | 43 pglob->gl_pathc = 0; |
44 //printf("could not find a file matching your search criteria\n"); | 44 //printf("could not find a file matching your search criteria\n"); |
45 return 1; | 45 return 1; |
46 } | 46 } else { |
47 else | 47 //printf("glob():ERROR:FindFirstFile: %i\n",GetLastError()); |
48 { | 48 return 1; |
49 //printf("glob():ERROR:FindFirstFile: %i\n",GetLastError()); | 49 } |
50 return 1; | 50 } |
51 } | 51 pglob->gl_pathv = malloc(sizeof(char *)); |
52 } | |
53 pglob->gl_pathv = malloc(sizeof(char*)); | |
54 pglob->gl_pathv[0] = strdup(found_file.cFileName); | 52 pglob->gl_pathv[0] = strdup(found_file.cFileName); |
55 pglob->gl_pathc++; | 53 pglob->gl_pathc++; |
56 while(1) | 54 while (1) { |
57 { | 55 if (!FindNextFile(searchhndl, &found_file)) { |
58 if(!FindNextFile(searchhndl,&found_file)) | 56 if (GetLastError() == ERROR_NO_MORE_FILES) { |
59 { | 57 //printf("glob(): no more files found\n"); |
60 if(GetLastError()==ERROR_NO_MORE_FILES) | |
61 { | |
62 //printf("glob(): no more files found\n"); | |
63 break; | 58 break; |
64 } | 59 } else { |
65 else | 60 //printf("glob():ERROR:FindNextFile:%i\n",GetLastError()); |
66 { | 61 return 1; |
67 //printf("glob():ERROR:FindNextFile:%i\n",GetLastError()); | 62 } |
68 return 1; | 63 } else { |
69 } | |
70 } | |
71 else | |
72 { | |
73 //printf("glob: found file %s\n",found_file.cFileName); | 64 //printf("glob: found file %s\n",found_file.cFileName); |
74 pglob->gl_pathc++; | 65 pglob->gl_pathc++; |
75 pglob->gl_pathv = realloc(pglob->gl_pathv,pglob->gl_pathc * sizeof(char*)); | 66 pglob->gl_pathv = realloc(pglob->gl_pathv, pglob->gl_pathc * sizeof(char *)); |
76 pglob->gl_pathv[pglob->gl_pathc-1] = strdup(found_file.cFileName); | 67 pglob->gl_pathv[pglob->gl_pathc - 1] = strdup(found_file.cFileName); |
77 } | 68 } |
78 } | 69 } |
79 FindClose(searchhndl); | 70 FindClose(searchhndl); |
80 return 0; | 71 return 0; |
81 } | 72 } |
82 | 73 |
83 void globfree(glob_t *pglob) | 74 void globfree(glob_t *pglob) |
84 { | 75 { |
85 int i; | 76 int i; |
86 for(i=0; i <pglob->gl_pathc ;i++) | 77 for (i = 0; i < pglob->gl_pathc; i++) |
87 { | 78 free(pglob->gl_pathv[i]); |
88 free(pglob->gl_pathv[i]); | 79 free(pglob->gl_pathv); |
89 } | |
90 free(pglob->gl_pathv); | |
91 } | 80 } |
92 | 81 |
93 #if 0 | 82 #if 0 |
94 int main(void){ | 83 int main(void) |
95 glob_t gg; | 84 { |
96 printf("globtest\n"); | 85 glob_t gg; |
97 glob( "*.jpeg",0,NULL,&gg ); | 86 printf("globtest\n"); |
98 { | 87 glob("*.jpeg", 0, NULL, &gg); |
88 { | |
99 int i; | 89 int i; |
100 for(i=0;i<gg.gl_pathc;i++)printf("GLOBED:%i %s\n",i,gg.gl_pathv[i]); | 90 for (i = 0; i < gg.gl_pathc; i++) |
91 printf("GLOBED:%i %s\n", i, gg.gl_pathv[i]); | |
101 } | 92 } |
102 globfree(&gg); | 93 globfree(&gg); |
103 | 94 |
104 return 0; | 95 return 0; |
105 } | 96 } |
97 | |
106 #endif | 98 #endif |