コード例 #1
0
/**
 * @brief internal find-files-in-a-single-datadir-function
 * @param dir path in which to start looking
 * @param pattern pattern to search for
 * @param recurse whether or not to recursively search
 * @param include_dirs whether or not to include directory names in the result
 * @return vector of std::strings
 *
 * Will search for a file given a particular pattern.
 * Starts from dirpath, descending down if recurse is true.
 */
void FileSystemHandler::FindFilesSingleDir(std::vector<std::string>& matches, const std::string& dir, const std::string &pattern, int flags) const
{
	assert(!dir.empty() && dir[dir.length() - 1] == native_path_separator);

	boost::regex regexpattern(filesystem.glob_to_regex(pattern));

	::FindFiles(matches, dir, regexpattern, flags);
}
コード例 #2
0
/**
 * @brief find files
 * @param dir path in which to start looking
 * @param pattern pattern to search for
 * @param recurse whether or not to recursively search
 * @param include_dirs whether or not to include directory names in the result
 * @return vector of std::strings
 *
 * Will search for a file given a particular pattern.
 * Starts from dirpath, descending down if recurse is true.
 */
std::vector<std::string> WinFileSystemHandler::FindFiles(const std::string& dir, const std::string &pattern, int flags) const
{
    assert(!dir.empty() && dir[dir.length() - 1] == '\\');

    std::vector<std::string> matches;
    boost::regex regexpattern(filesystem.glob_to_regex(pattern));

    ::FindFiles(matches, dir, regexpattern, flags);

    return matches;
}
コード例 #3
0
/**
 * @brief internal find-files-in-a-single-datadir-function
 * @param dir path in which to start looking
 * @param pattern pattern to search for
 * @param recurse whether or not to recursively search
 * @param include_dirs whether or not to include directory names in the result
 * @return vector of std::strings
 *
 * Will search for a file given a particular pattern.
 * Starts from dirpath, descending down if recurse is true.
 */
std::vector<std::string> UnixFileSystemHandler::FindFilesSingleDir(const std::string& dir, const std::string &pattern, bool recurse, bool include_dirs) const
{
	assert(!dir.empty() && dir[dir.length() - 1] == '/');

	std::vector<std::string> matches;
	boost::regex regexpattern(filesystem.glob_to_regex(pattern));

	::FindFiles(matches, dir, regexpattern, recurse, include_dirs);

	return matches;
}
コード例 #4
0
/**
 * @brief find files
 * @param dirpath path in which to start looking
 * @param pattern pattern to search for
 * @param recurse whether or not to recursively search
 * @param include_dirs whether or not to include directory names in the result
 * @return vector of std::strings
 *
 * Will search for a file given a particular pattern.
 * Starts from dirpath, descending down if recurse is true.
 */
std::vector<std::string> FileSystemHandler::FindFiles(const std::string& dir, const std::string &pattern, bool recurse, bool include_dirs) const
{
	std::vector<std::string> matches;
	boost::filesystem::path dirpath(dir, boost::filesystem::no_check);
	if (boost::filesystem::exists(dirpath) && boost::filesystem::is_directory(dirpath)) {
		boost::regex regexpattern(filesystem.glob_to_regex(pattern));
		matches = ::FindFiles(dirpath, regexpattern, recurse, include_dirs);
	} else {
#ifdef DEBUG
		fprintf(stderr,"find_files warning: search path %s is not a directory\n",dirpath.string().c_str());
#endif
	}
	return matches;
}