OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include <time.h> | 8 #include <time.h> |
9 #include <dirent.h> | 9 #include <dirent.h> |
| 10 #include <glob.h> |
10 #include "SkOSFile.h" | 11 #include "SkOSFile.h" |
11 #include "skpdiff_util.h" | 12 #include "skpdiff_util.h" |
12 | 13 |
13 const char* cl_error_to_string(cl_int err) { | 14 const char* cl_error_to_string(cl_int err) { |
14 switch (err) { | 15 switch (err) { |
15 case CL_SUCCESS: return "CL_SUCCESS"; | 16 case CL_SUCCESS: return "CL_SUCCESS"; |
16 case CL_DEVICE_NOT_FOUND: return "CL_DEVICE_NOT_FOUND"; | 17 case CL_DEVICE_NOT_FOUND: return "CL_DEVICE_NOT_FOUND"; |
17 case CL_DEVICE_NOT_AVAILABLE: return "CL_DEVICE_NOT_AVAILABLE
"; | 18 case CL_DEVICE_NOT_AVAILABLE: return "CL_DEVICE_NOT_AVAILABLE
"; |
18 case CL_COMPILER_NOT_AVAILABLE: return "CL_COMPILER_NOT_AVAILAB
LE"; | 19 case CL_COMPILER_NOT_AVAILABLE: return "CL_COMPILER_NOT_AVAILAB
LE"; |
19 case CL_MEM_OBJECT_ALLOCATION_FAILURE: return "CL_MEM_OBJECT_ALLOCATIO
N_FAILURE"; | 20 case CL_MEM_OBJECT_ALLOCATION_FAILURE: return "CL_MEM_OBJECT_ALLOCATIO
N_FAILURE"; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // dirent only gives relative paths, we need to join them to the base pa
th to check if they | 84 // dirent only gives relative paths, we need to join them to the base pa
th to check if they |
84 // are directories. | 85 // are directories. |
85 SkString joinedPath = SkOSPath::SkPathJoin(path, entry->d_name); | 86 SkString joinedPath = SkOSPath::SkPathJoin(path, entry->d_name); |
86 | 87 |
87 // We only care about files | 88 // We only care about files |
88 if (!sk_isdir(joinedPath.c_str())) { | 89 if (!sk_isdir(joinedPath.c_str())) { |
89 entries->push_back(SkString(entry->d_name)); | 90 entries->push_back(SkString(entry->d_name)); |
90 } | 91 } |
91 } | 92 } |
92 | 93 |
| 94 closedir(dir); |
| 95 |
93 return true; | 96 return true; |
94 } | 97 } |
| 98 |
| 99 bool glob_files(const char globPattern[], SkTArray<SkString>* entries) { |
| 100 // TODO Make sure this works on windows. This may require use of FindNextFil
e windows function. |
| 101 glob_t globBuffer; |
| 102 if (glob(globPattern, 0, NULL, &globBuffer) != 0) { |
| 103 return false; |
| 104 } |
| 105 |
| 106 // Note these paths are in sorted order by default according to http://linux
.die.net/man/3/glob |
| 107 // Check under the flag GLOB_NOSORT |
| 108 char** paths = globBuffer.gl_pathv; |
| 109 while(NULL != *paths) { |
| 110 entries->push_back(SkString(*paths)); |
| 111 paths++; |
| 112 } |
| 113 |
| 114 globfree(&globBuffer); |
| 115 |
| 116 return true; |
| 117 } |
OLD | NEW |