Remove filename from path
Jay Norwood via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Sep 25 20:40:35 PDT 2014
On Friday, 26 September 2014 at 03:32:46 UTC, Jay Norwood wrote:
> On Wednesday, 24 September 2014 at 10:28:05 UTC, Suliman wrote:
>>>> string path = thisExePath()
>>>
>>> Seems like "dirName" in std.path is a good candidate ;)
>>> http://dlang.org/phobos/std_path.html#.dirName
>>>
>>> You'll find many other path manipulation functions there.
>>
>> Thanks! But if I want to strip it, how I can cut it?
> dirName gives the directory, baseName the filename,
> stripExtension strips it, so seems like what you want is
> dirName ~ stripExtension( baseName )
easier than that. Looks like stripExtension handles the whole
path.
assert (stripExtension("dir/file.ext") == "dir/file");
More information about the Digitalmars-d-learn
mailing list