/* See gdbsupport/pathstuff.h. */
std::string
-gdb_abspath (const char *path)
+gdb_abspath (const char *path, const char *cwd)
{
gdb_assert (path != NULL && path[0] != '\0');
if (path[0] == '~')
return gdb_tilde_expand (path);
- if (IS_ABSOLUTE_PATH (path) || current_directory == NULL)
+ if (IS_ABSOLUTE_PATH (path) || cwd == NULL)
return path;
- return path_join (current_directory, path);
+ return path_join (cwd, path);
}
/* See gdbsupport/pathstuff.h. */
/* Path utilities. */
+/* String containing the current directory (what getwd would return). */
+extern char *current_directory;
+
/* Return the real path of FILENAME, expanding all the symbolic links.
Contrary to "gdb_abspath", this function does not use
PATH cannot be NULL or the empty string.
This does not resolve symlinks however, use gdb_realpath for that.
- Contrary to "gdb_realpath", this function uses CURRENT_DIRECTORY
- for the path expansion. This may lead to scenarios the current
- working directory (CWD) is different than CURRENT_DIRECTORY.
+ Contrary to "gdb_realpath", this function uses CWD for the path
+ expansion. This may lead to scenarios the current working
+ directory is different than CWD.
- If CURRENT_DIRECTORY is NULL, this function returns a copy of
- PATH. */
+ If CWD is NULL, this function returns a copy of PATH. */
-extern std::string gdb_abspath (const char *path);
+extern std::string gdb_abspath (const char *path,
+ const char *cwd = current_directory);
/* Overload of gdb_abspath which takes std::string. */
extern gdb::char_vector make_temp_filename (const std::string &f);
-/* String containing the current directory (what getwd would return). */
-extern char *current_directory;
-
#endif /* COMMON_PATHSTUFF_H */