forked from lix-project/lix
absPath(): Use std::optional
This commit is contained in:
parent
6fadb3fc03
commit
1bf9eb21b7
|
@ -98,10 +98,10 @@ void replaceEnv(std::map<std::string, std::string> newEnv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path absPath(Path path, Path dir)
|
Path absPath(Path path, std::optional<Path> dir)
|
||||||
{
|
{
|
||||||
if (path[0] != '/') {
|
if (path[0] != '/') {
|
||||||
if (dir == "") {
|
if (!dir) {
|
||||||
#ifdef __GNU__
|
#ifdef __GNU__
|
||||||
/* GNU (aka. GNU/Hurd) doesn't have any limitation on path
|
/* GNU (aka. GNU/Hurd) doesn't have any limitation on path
|
||||||
lengths and doesn't define `PATH_MAX'. */
|
lengths and doesn't define `PATH_MAX'. */
|
||||||
|
@ -117,7 +117,7 @@ Path absPath(Path path, Path dir)
|
||||||
free(buf);
|
free(buf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
path = dir + "/" + path;
|
path = *dir + "/" + path;
|
||||||
}
|
}
|
||||||
return canonPath(path);
|
return canonPath(path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ void clearEnv();
|
||||||
/* Return an absolutized path, resolving paths relative to the
|
/* Return an absolutized path, resolving paths relative to the
|
||||||
specified directory, or the current directory otherwise. The path
|
specified directory, or the current directory otherwise. The path
|
||||||
is also canonicalised. */
|
is also canonicalised. */
|
||||||
Path absPath(Path path, Path dir = "");
|
Path absPath(Path path, std::optional<Path> dir = {});
|
||||||
|
|
||||||
/* Canonicalise a path by removing all `.' or `..' components and
|
/* Canonicalise a path by removing all `.' or `..' components and
|
||||||
double or trailing slashes. Optionally resolves all symlink
|
double or trailing slashes. Optionally resolves all symlink
|
||||||
|
|
Loading…
Reference in a new issue