7 #if defined _WIN32 || defined WINCE 20 #if defined(WINRT) || defined(_WIN32_WCE) 21 WIN32_FIND_DATAW
data;
23 WIN32_FIND_DATAA
data;
37 DIR* opendir(
const char*
path )
41 #if defined(WINRT) || defined(_WIN32_WCE) 43 wchar_t wfull_path[MAX_PATH];
44 size_t copied = mbstowcs( wfull_path, full_path.c_str(), MAX_PATH );
45 CV_Assert( (copied != MAX_PATH) && (copied != (
size_t)-1) );
46 dir->handle = ::FindFirstFileExW( wfull_path, FindExInfoStandard,
47 &dir->data, FindExSearchNameMatch,
NULL, 0 );
49 dir->handle = ::FindFirstFileExA( (
std::string( path ) +
"\\*").c_str(),
50 FindExInfoStandard, &dir->data, FindExSearchNameMatch,
NULL, 0 );
52 if( dir->handle == INVALID_HANDLE_VALUE )
61 dirent* readdir( DIR* dir )
63 #if defined(WINRT) || defined(_WIN32_WCE) 64 if( dir->ent.d_name != 0 )
66 if( ::FindNextFileW( dir->handle, &dir->data ) !=
TRUE )
69 size_t asize = wcstombs(
NULL, dir->data.cFileName, 0 );
70 CV_Assert( (asize != 0) && (asize != (
size_t)-1) );
71 char* aname =
new char[asize + 1];
73 wcstombs( aname, dir->data.cFileName, asize );
74 dir->ent.d_name = aname;
76 if( dir->ent.d_name != 0 )
78 if( ::FindNextFileA( dir->handle, &dir->data ) !=
TRUE )
81 dir->ent.d_name = dir->data.cFileName;
86 void closedir( DIR* dir )
88 ::FindClose( dir->handle );
96 # include <sys/stat.h> 104 static const char native_separator =
'/';
110 return c ==
'/' || c ==
'\\';
123 if( baseSep && pathSep )
125 result = base + path.substr( 1 );
127 else if( !baseSep && !pathSep )
129 result = base + native_separator +
path;
133 result = base +
path;
138 static bool wildcmp(
const char *
string,
const char *wild )
141 const char *
cp = 0, *mp = 0;
143 while( (*
string) && (*wild !=
'*') )
145 if( (*wild != *
string) && (*wild !=
'?') )
166 else if( (*wild == *
string) || (*wild ==
'?') )
178 while( *wild ==
'*' )
189 #if defined _WIN32 || defined WINCE 193 attributes = dir->data.dwFileAttributes;
196 WIN32_FILE_ATTRIBUTE_DATA all_attrs;
198 wchar_t wpath[MAX_PATH];
199 size_t copied = mbstowcs( wpath, path.c_str(), MAX_PATH );
200 CV_Assert( (copied != MAX_PATH) && (copied != (
size_t)-1) );
201 status = ::GetFileAttributesExW( wpath, GetFileExInfoStandard, &all_attrs );
203 status = ::GetFileAttributesExA( path.c_str(), GetFileExInfoStandard, &all_attrs );
205 attributes = all_attrs.dwFileAttributes;
208 return status && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
211 struct stat stat_buf;
212 if( 0 != stat( path.c_str(), &stat_buf ) )
214 int is_dir = S_ISDIR( stat_buf.st_mode );
221 std::vector<std::string>&
result,
223 bool includeDirectories,
229 if( (dir = opendir( directory.c_str() )) != 0 )
235 while( (ent = readdir( dir )) != 0 )
237 const char*
name = ent->d_name;
238 if( (name[0] == 0) || (name[0] ==
'.' && name[1] == 0) || (name[0] ==
'.' && name[1] ==
'.' && name[2] == 0) )
244 if(
isDir( path, dir ) )
247 glob_rec( path, wildchart, result, recursive, includeDirectories, entry );
248 if( !includeDirectories )
252 if( wildchart.empty() ||
wildcmp( name, wildchart.c_str() ) )
253 result.push_back( entry );
273 bool recursive =
true,
274 bool includeDirectories =
false 277 std::vector< std::string > results;
278 glob_rec( directory, spec, results, recursive, includeDirectories,
"" );
279 for(
auto r : results )
289 auto x = path.find_last_of( dir_separators );
290 if(
x == std::string::npos )
293 *basename = path.substr(
x + 1 );
static bool isDir(const std::string &path, DIR *dir)
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
GLuint const GLchar * name
std::string join(const std::string &base, const std::string &path)
static bool wildcmp(const char *string, const char *wild)
GLuint64 GLenum void * handle
GLsizei const GLchar *const * path
static void glob(const std::string &directory, const std::string &spec, std::function< void(std::string const &) > fn, bool recursive=true, bool includeDirectories=false)
static void glob_rec(const std::string &directory, const std::string &wildchart, std::vector< std::string > &result, bool recursive, bool includeDirectories, const std::string &pathPrefix)
static bool isPathSeparator(char c)
GLsizei const GLchar *const * string
::std_msgs::String_< std::allocator< void > > String
static std::string get_parent(std::string const &path, std::string *basename=nullptr)
status
Defines return codes that SDK interfaces use. Negative values indicate errors, a zero value indicates...
const char dir_separators[]
static const char native_separator