1 #ifdef _WIN32
2 #define _WIN32_WINNT 0x501
3 #include <string>
4 #include <afx.h>
5 #include "winargs.h"
6 #include "winglob.h"
7 
winargs_get_wildcard(const char * arg,std::vector<std::string> & files)8 void winargs_get_wildcard(const char *arg, std::vector<std::string> &files) {
9 	std::wstring argw;
10 	str_to_utf16z(arg, argw);
11 
12 	CFileFind finder;
13 	if (!finder.FindFile(argw.c_str())) {
14 		// It wasn't found.  Add the original arg for sane error handling.
15 		files.push_back(arg);
16 	} else {
17 		BOOL hasMore = TRUE;
18 		while (hasMore) {
19 			// Confusingly, FindNextFile returns false on the last file.
20 			hasMore = finder.FindNextFile();
21 			if (finder.IsDots()) {
22 				continue;
23 			}
24 
25 			std::string filename;
26 			str_to_utf8z(finder.GetFilePath().GetString(), filename);
27 			// Now truncate off the null - we don't need it here.
28 			if (!filename.empty()) {
29 				filename.resize(filename.size() - 1);
30 			}
31 			files.push_back(filename);
32 		}
33 	}
34 	finder.Close();
35 }
36 #endif
37