From d1ea17711bfc80eb0e6124ca2de251aeeb4f1475 Mon Sep 17 00:00:00 2001 From: stephena Date: Sat, 11 Jun 2011 15:58:42 +0000 Subject: [PATCH] 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 --- src/unix/FSNodePOSIX.cxx | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/unix/FSNodePOSIX.cxx b/src/unix/FSNodePOSIX.cxx index 761fc9949..0c93a40a2 100644 --- a/src/unix/FSNodePOSIX.cxx +++ b/src/unix/FSNodePOSIX.cxx @@ -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;