Bugfix: Reading files on Windows (recognizing relative or absoulte path) Author: Vanja Skuric

This commit is contained in:
Robert Keser 2017-04-17 15:27:50 +02:00
parent e2a3e46122
commit 64eed6d825
5 changed files with 36 additions and 15 deletions

View file

@ -126,7 +126,7 @@ void printSourceFileAndLine
myAddress = nStream.str();
}
if (filename[0] == '/')
if (filename[0] == '/' || filename[1] == ':')
{
string line = pOpen
(
@ -266,7 +266,10 @@ void getSymbolForRaw
const word& address
)
{
if (filename.size() && filename[0] == '/')
if
(
filename.size() && (filename[0] == '/' || filename[1] == ':')
)
{
string fcnt = pOpen
(
@ -316,7 +319,10 @@ void error::printStack(Ostream& os)
string::size_type space = line.rfind(' ') + 1;
fileName libPath = line.substr(space, line.size()-space);
if (libPath.size() && libPath[0] == '/')
if
(
libPath.size() && (libPath[0] == '/' || libPath[1] == ':')
)
{
string offsetString(line.substr(0, line.find('-')));
IStringStream offsetStr(offsetString);
@ -359,10 +365,10 @@ void error::printStack(Ostream& os)
programFile = msg.substr(0, min(spacePos, bracketPos));
// not an absolute path
if (programFile[0] != '/')
if (programFile[0] != '/' && programFile[1] != ':')
{
string tmp = pOpen("which " + programFile);
if (tmp[0] == '/' || tmp[0] == '~')
if (tmp[0] == '/' || tmp[1] == ':' || tmp[0] == '~')
{
programFile = tmp;
}

View file

@ -130,7 +130,7 @@ void printSourceFileAndLine
}
#ifndef darwin
if (filename[0] == '/')
if (filename[0] == '/' || filename[1] == ':')
#else
if (1)
#endif
@ -175,7 +175,10 @@ void getSymbolForRaw
const word& address
)
{
if (filename.size() && filename[0] == '/')
if
(
filename.size() && (filename[0] == '/' || filename[1] == ':')
)
{
string fcnt = pOpen
(
@ -224,7 +227,10 @@ void error::printStack(Ostream& os)
string::size_type space = line.rfind(' ') + 1;
fileName libPath = line.substr(space, line.size()-space);
if (libPath.size() && libPath[0] == '/')
if
(
libPath.size() && (libPath[0] == '/' || libPath[1] == ':')
)
{
string offsetString(line.substr(0, line.find('-')));
IStringStream offsetStr(offsetString);
@ -268,10 +274,10 @@ void error::printStack(Ostream& os)
programFile = msg.substr(0, min(spacePos, bracketPos));
// not an absolute path
if (programFile[0] != '/')
if (programFile[0] != '/' && programFile[1] != ':')
{
string tmp = pOpen("which " + programFile);
if (tmp[0] == '/' || tmp[0] == '~')
if (tmp[0] == '/' || tmp[1] == ':' || tmp[0] == '~')
{
programFile = tmp;
}

View file

@ -77,7 +77,7 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName
fileName fName(is);
fName.expand();
if (fName.size() && fName[0] != '/')
if (fName.size() && fName[0] != '/' && fName[1] != ':')
{
fName = fileName(is.name()).path()/fName;
}

View file

@ -159,7 +159,10 @@ void Foam::argList::getRootCase()
casePath = cwd();
options_.erase("case");
}
else if (casePath[0] != '/' && casePath.name() == "..")
else if
(
casePath[0] != '/' && casePath[1] != ':' && casePath.name() == ".."
)
{
// avoid relative cases ending in '..' - makes for very ugly names
casePath = cwd()/casePath;
@ -177,7 +180,7 @@ void Foam::argList::getRootCase()
case_ = globalCase_;
// Set the case and case-name as an environment variable
if (rootPath_[0] == '/')
if (rootPath_[0] == '/' || rootPath_[1] == ':')
{
// Absolute path - use as-is
setEnv("FOAM_CASE", rootPath_/globalCase_, true);

View file

@ -884,12 +884,18 @@ Foam::chemkinReader::chemkinReader(const dictionary& thermoDict)
fileName relPath = thermoDict.name().path();
if (relPath.size())
{
if (chemkinFile.size() && chemkinFile[0] != '/')
if
(
chemkinFile.size() && chemkinFile[0] != '/' && chemkinFile[1] != ':'
)
{
chemkinFile = relPath/chemkinFile;
}
if (thermoFile.size() && thermoFile[0] != '/')
if
(
thermoFile.size() && thermoFile[0] != '/' && thermoFile[1] != ':'
)
{
thermoFile = relPath/thermoFile;
}