Reputation: 19
how to get list of all files in a directory and sub directories(full file path), And also show it if the file name is in Russian and Arabic I did a lot of searching on Google but did not find anything that would solve my problem, any help is appreciated
Upvotes: 0
Views: 1318
Reputation: 2119
It is better to include what you have tried so far to solve your problem. That way we can help you debug your own code which can be very good for you.
However, C++17 made iterating over directories very easy through the directory iterator. Read more about the directory iterator here and see the code below:
#include <string>
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
std::string path = "/path/to/directory";
for (const auto & entry : fs::directory_iterator(path))
std::cout << entry.path() << std::endl;
}
Now second part of your question: you have entries paths, you can extract the file name out of it. Then, suppose you have two dictionaries one Russian and the other is Arabic. If you iterate over the filename character by character and check every time whether it is in the Russian dictionary or the Arabic one, you get the idea!
What you need to know is Arabic, Russian, whatever character has a Unicode code point (What's unicode?); meaning there is a unique value for it. Computers are good with 0s and 1s but not human readable characters (ASCII was made to solve this specific problem). If you are familiar with ASCII, you can consider Unicode as more inclusive character encoding standard. For instance see this page for Arabic characters encoding.
PS: Use hashtables implementations (instead of arrays) for your dictionary, since it has an amortized O(1) lookup.
Upvotes: 2