>>>> eg executable, non-directory. */
int
openp (const char *path, openp_flags opts, const char *string,
- int mode, gdb::unique_xmalloc_ptr<char> *filename_opened)
+ int mode, gdb::unique_xmalloc_ptr<char> *filename_opened,
+ const char *cwd)
{
int fd;
char *filename;
int newlen;
/* First, realloc the filename buffer if too short. */
- len = strlen (current_directory);
+ len = strlen (cwd);
newlen = len + strlen (string) + 2;
if (newlen > alloclen)
{
alloclen = newlen;
filename = (char *) alloca (alloclen);
}
- strcpy (filename, current_directory);
+ strcpy (filename, cwd);
}
else if (strchr(dir, '~'))
{
*filename_opened = gdb_realpath (filename);
else
*filename_opened
- = make_unique_xstrdup (gdb_abspath (filename).c_str ());
+ = make_unique_xstrdup (gdb_abspath (filename, cwd).c_str ());
}
errno = last_errno;
#ifndef SOURCE_H
#define SOURCE_H
+#include "gdbsupport/pathstuff.h"
#include "gdbsupport/scoped_fd.h"
struct program_space;
DEF_ENUM_FLAGS_TYPE(openp_flag, openp_flags);
extern int openp (const char *, openp_flags, const char *, int,
- gdb::unique_xmalloc_ptr<char> *);
+ gdb::unique_xmalloc_ptr<char> *,
+ const char *cwd = current_directory);
extern int source_full_path_of (const char *, gdb::unique_xmalloc_ptr<char> *);