sargon.path.stripext
This module contains stripExt(). Authors:Lars Tandle Kyllingstad, Walter Bright, Grzegorz Adam Hankiewicz, Thomas Kühne, Andrei Alexandrescu License:
Boost License 1.0 Source:
src/sargon/path/stripext.d
- auto stripExt(R)(R path);
- Returns slice of path[] with the extension stripped off.
stripExt is an algorithm that does not allocate nor throw, it is pure and @safe.
Parameters:
Returns:R path a RandomAccessRange that can be sliced.
a slice of path Examples:assert (stripExt("file") == "file"); assert (stripExt("file.ext") == "file"); assert (stripExt("file.ext1.ext2") == "file.ext1"); assert (stripExt("file.") == "file"); assert (stripExt(".file") == ".file"); assert (stripExt(".file.ext") == ".file"); assert (stripExt("dir/file.ext") == "dir/file"); { import std.internal.scopebuffer; char[10] tmpbuf = void; auto buf = ScopeBuffer!char(tmpbuf); scope(exit) buf.free(); buf.length = 0; "file.ext".byChar().stripExt().copy(&buf); assert(buf[] == "file"); }