Skip to content

Commit

Permalink
Fix issue where getAbsolutePath would strip off the first two charact…
Browse files Browse the repository at this point in the history
…ers of the file name.
  • Loading branch information
nealkruis committed Oct 2, 2020
1 parent c784950 commit 7fc1c6f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/EnergyPlus/FileSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,14 @@ namespace FileSystem {
}

std::string pathTail;
if (parentPath == ".")
std::string currentDir = ".";
std::string currentDirWithSep = currentDir + DataStringGlobals::pathChar;
if ((parentPath == currentDir || parentPath == currentDirWithSep) && path.find(currentDirWithSep) == std::string::npos)
// If parent path is the current directory and the original path does not already contain
// the current directory in the string, then leave the path tail as-is.
pathTail = path;
else
// otherwise strip off any preceding content from the path tail
pathTail = path.substr(parentPath.size(), path.size() - parentPath.size());

char *absolutePathTemp = realpath(parentPath.c_str(), NULL);
Expand Down

0 comments on commit 7fc1c6f

Please sign in to comment.