Function gkfs::path::prepend_path(const string&, const char *)

Function Documentation

string gkfs::path::prepend_path(const string &prefix_path, const char *raw_path)

Add path prefix to a given C string.

Returns a string composed by the prefix_path followed by raw_path.

This would return the same of:

string(raw_path).append(prefix_path);
But it is faster because it avoids to copy the raw_path twice.

Time cost approx: O(len(prefix_path)) + 2 O(len(raw_path))

Example:

prepend_path("/tmp/prefix", "./my/path") == "/tmp/prefix/./my/path"