range with the result
import std.array; assert(withDefaultExtension("file", "ext").array == "file.ext"); assert(withDefaultExtension("file"w, ".ext").array == "file.ext"w); assert(withDefaultExtension("file.", "ext").array == "file."); assert(withDefaultExtension("file", "").array == "file."); import std.utf : byChar, byWchar; assert(withDefaultExtension("file".byChar, "ext").array == "file.ext"); assert(withDefaultExtension("file"w.byWchar, ".ext").array == "file.ext"w); assert(withDefaultExtension("file.".byChar, "ext"d).array == "file."); assert(withDefaultExtension("file".byChar, "").array == "file.");
Set the extension of path to ext if path doesn't have one.