Exemplo n.º 1
0
 bfs::path GetParentPath(const bfs::path& path) {
     #if defined(USE_BOOST_FILESYSTEM_V3) || defined(USE_NON_DEPRECATED_BOOST_FILESYSTEM_V2)
         return path.parent_path();
     #else
         return path.branch_path();
     #endif
 }
Exemplo n.º 2
0
PWIZ_API_DECL void expand_pathmask(const bfs::path& pathmask,
                                   vector<bfs::path>& matchingPaths)
{
    using bfs::path;

#ifdef WIN32
    path maskParentPath = pathmask.branch_path();
	WIN32_FIND_DATA fdata;
	HANDLE srcFile = FindFirstFileEx(pathmask.string().c_str(), FindExInfoStandard, &fdata, FindExSearchNameMatch, NULL, 0);
	if (srcFile == INVALID_HANDLE_VALUE)
		return; // no matches

    do
    {
        if (strcmp(fdata.cFileName, ".") != 0 &&
            strcmp(fdata.cFileName, "..") != 0)
	        matchingPaths.push_back( maskParentPath / fdata.cFileName );
    }
    while (FindNextFile(srcFile, &fdata));

	FindClose(srcFile);

#else

	glob_t globbuf;
	int rv = glob(pathmask.string().c_str(), 0, NULL, &globbuf);
	if(rv > 0 && rv != GLOB_NOMATCH)
		throw runtime_error("FindFilesByMask(): glob() error");

	DIR* curDir = opendir(".");
	struct stat curEntryData;

	for (size_t i=0; i < globbuf.gl_pathc; ++i)
	{
		stat(globbuf.gl_pathv[i], &curEntryData);
		if (S_ISDIR(curEntryData.st_mode) ||
            S_ISREG(curEntryData.st_mode) ||
            S_ISLNK(curEntryData.st_mode))
			matchingPaths.push_back(globbuf.gl_pathv[i]);
	}
	closedir(curDir);

	globfree(&globbuf);

#endif
}