Debian Codegraph @

cvd_src/Win32/win32.cpp

raw symbols SCIP
1 #include <algorithm>
2 #include <cassert>
3 #include <io.h>
4 #include <stdlib.h>
5 #include <string>
6 #include <time.h>
7 #include <vector>
8
9 namespace CVD
10 {
11
12 namespace Internal
13 {
14
15 void* aligned_alloc(size_t count, size_t alignment)
16 {
17 return _aligned_malloc(count, alignment);
18 }
19
20 void aligned_free(void* memory)
21 {
22 _aligned_free(memory);
23 }
24
25 } // namespace Internal
26
27 // returns path component from a general path string
28 static std::string get_path(const std::string& p)
29 {
30 char drive[_MAX_DRIVE];
31 char dir[_MAX_DIR];
32 char out[1024];
33
34 errno_t ret = _splitpath_s(p.c_str(), drive, _MAX_DRIVE, dir, _MAX_DIR, NULL, 0, NULL, 0);
35 assert(0 == ret);
36 _makepath(out, drive, dir, NULL, NULL);
37 return std::string(out);
38 }
39
40 // simple implementation of globlist after MSDN example for _findfirst
41 std::vector<std::string> globlist(const std::string& gl)
42 {
43 std::vector<std::string> ret;
44
45 struct _finddatai64_t c_file;
46 intptr_t hFile;
47
48 // get the path component to stick it to the front again
49 const std::string path = get_path(gl);
50
51 // Find first file in current directory
52 if((hFile = _findfirsti64(gl.c_str(), &c_file)) != -1L)
53 {
54 do
55 {
56 ret.push_back(path + c_file.name);
57 } while(_findnexti64(hFile, &c_file) == 0);
58 _findclose(hFile);
59 }
60 std::sort(ret.begin(), ret.end());
61 return ret;
62 }
63
64 } // namespace CVD