mirror of https://github.com/stella-emu/stella.git
Remove notion of 'current directory' from the file handling
for UNIX systems. Pathnames are always accessed internally as full/absolute pathnames, and while they can be loaded and saved with the '~' symbol (to indicate the users home directory), they are still always mapped to absolute paths. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2252 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
cb3f0e96ba
commit
d1ea17711b
|
@ -129,8 +129,8 @@ POSIXFilesystemNode::POSIXFilesystemNode()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
POSIXFilesystemNode::POSIXFilesystemNode(const string& p, bool verify)
|
||||
{
|
||||
// Expand "~/" to the value of the HOME env variable
|
||||
if ( p.length() >= 2 && p[0] == '~' && p[1] == '/')
|
||||
// Expand '~/' and './' to the value of the HOME env variable
|
||||
if ( p.length() >= 2 && (p[0] == '~' || p[0] == '.') && p[1] == '/')
|
||||
{
|
||||
const char *home = getenv("HOME");
|
||||
#ifdef MAXPATHLEN
|
||||
|
@ -140,32 +140,11 @@ POSIXFilesystemNode::POSIXFilesystemNode(const string& p, bool verify)
|
|||
#endif
|
||||
{
|
||||
_path = home;
|
||||
// Skip over the tilde. We know that p contains at least
|
||||
// Skip over the tilde/dot. We know that p contains at least
|
||||
// two chars, so this is safe:
|
||||
_path += p.c_str() + 1;
|
||||
}
|
||||
}
|
||||
// Expand "./" to the current directory
|
||||
else if ( p.length() >= 2 && p[0] == '.' && p[1] == '/')
|
||||
{
|
||||
#ifdef MAXPATHLEN
|
||||
char buf[MAXPATHLEN];
|
||||
char* ret = getcwd(buf, MAXPATHLEN);
|
||||
#else // No MAXPATHLEN, as happens on Hurd
|
||||
char* ret = get_current_dir_name();
|
||||
char* buf = ret;
|
||||
#endif
|
||||
if (ret == buf && ret != NULL)
|
||||
{
|
||||
_path = buf;
|
||||
// Skip over the dot. We know that p contains at least
|
||||
// two chars, so this is safe:
|
||||
_path += p.c_str() + 1;
|
||||
#ifndef MAXPATHLEN
|
||||
free(ret);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
_path = p;
|
||||
|
||||
|
|
Loading…
Reference in New Issue