Denis Koroskin wrote:
I have just started using iterators and algorithms a little.
Given a full file path, a needed to get folder name where it is located, and a name of the that file.

Using C and its standard library, I can do it as follows:

auto pos = strrpos(fullFilePath, '/'); // strrpos = strpos-reverse
string dirName = fullFilePath[0..pos];
string fileName = fullFilePath[pos+1..$];

I think you are confusing iterators with ranges. Iterators are gone from Phobos.

auto pos = fullFilePath.length - find(retro(fullFilePath)).length - 1;
auto dirname = fullFilePath[0..pos];
auto filename = fullFilePath[pos+1..$];


Andrei

Reply via email to