
Hello! This is my problem: I have an std::string contains something like C:\Test\Media\Cloud.dds. Now i want to extract the Cloud.dds. This is, what i have tried: fs::path temp(Name, fs::native); fs::directory_iterator dir_itr(temp); Name = dir_itr->leaf(); Where is my error? This code throughs an exception. Thanks, Christian Gmeiner

Hi Christian
I have an std::string contains something like C:\Test\Media\Cloud.dds. Now i want to extract the Cloud.dds.
This is, what i have tried: fs::path temp(Name, fs::native); fs::directory_iterator dir_itr(temp); Name = dir_itr->leaf();
Where is my error? This code throughs an exception.
The directory_iterator class expects a directory as its constructor argument, not a file. Use the following code to get the file name. fs::path temp(Name, fs::native); Name = temp.leaf(); If you do not need the path object, this should be the shortest way. Name = fs::path(Name, fs::native).leaf(); Best regards, Peter.
participants (2)
-
Christian Gmeiner
-
Peter Klotz