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:
stephena 2011-06-11 15:58:42 +00:00
parent cb3f0e96ba
commit d1ea17711b
1 changed files with 3 additions and 24 deletions

View File

@ -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;