I am using a vector to retrieve the names of the files into a path. I only want to get a certain type of file. That's why I am trying to use .find to detect if the file has the conllu format. I want to find out if a string contains "conllu" or not
void read_directory(const std::string& name, stringvec& v)
{
std::string pattern(name);
pattern.append("\\*");
WIN32_FIND_DATA data;
HANDLE hFind;
if ((hFind = FindFirstFile(pattern.c_str(), &data)) != INVALID_HANDLE_VALUE) {
while (FindNextFile(hFind, &data) != 0) {
v.push_back(data.cFileName);
}
FindClose(hFind);
}
}
std::vector<std::string> v;
std::vector<std::string>::iterator it;
read_directory("path", v);
it = find(v.begin(), v.end(), ".conllu");
if (it != v.end())
std::cout << "Element found in myvector: " << *it << '\n';
Example of file names in the vector :
.gitignore
CONTRIBUTING.md
el_gdt-ud-dev.conllu