Bugfix: Reading files on Windows (recognizing relative or absoulte path) Author: Vanja Skuric
This commit is contained in:
parent
e2a3e46122
commit
64eed6d825
5 changed files with 36 additions and 15 deletions
|
@ -126,7 +126,7 @@ void printSourceFileAndLine
|
||||||
myAddress = nStream.str();
|
myAddress = nStream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename[0] == '/')
|
if (filename[0] == '/' || filename[1] == ':')
|
||||||
{
|
{
|
||||||
string line = pOpen
|
string line = pOpen
|
||||||
(
|
(
|
||||||
|
@ -266,7 +266,10 @@ void getSymbolForRaw
|
||||||
const word& address
|
const word& address
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (filename.size() && filename[0] == '/')
|
if
|
||||||
|
(
|
||||||
|
filename.size() && (filename[0] == '/' || filename[1] == ':')
|
||||||
|
)
|
||||||
{
|
{
|
||||||
string fcnt = pOpen
|
string fcnt = pOpen
|
||||||
(
|
(
|
||||||
|
@ -316,7 +319,10 @@ void error::printStack(Ostream& os)
|
||||||
string::size_type space = line.rfind(' ') + 1;
|
string::size_type space = line.rfind(' ') + 1;
|
||||||
fileName libPath = line.substr(space, line.size()-space);
|
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('-')));
|
string offsetString(line.substr(0, line.find('-')));
|
||||||
IStringStream offsetStr(offsetString);
|
IStringStream offsetStr(offsetString);
|
||||||
|
@ -359,10 +365,10 @@ void error::printStack(Ostream& os)
|
||||||
programFile = msg.substr(0, min(spacePos, bracketPos));
|
programFile = msg.substr(0, min(spacePos, bracketPos));
|
||||||
|
|
||||||
// not an absolute path
|
// not an absolute path
|
||||||
if (programFile[0] != '/')
|
if (programFile[0] != '/' && programFile[1] != ':')
|
||||||
{
|
{
|
||||||
string tmp = pOpen("which " + programFile);
|
string tmp = pOpen("which " + programFile);
|
||||||
if (tmp[0] == '/' || tmp[0] == '~')
|
if (tmp[0] == '/' || tmp[1] == ':' || tmp[0] == '~')
|
||||||
{
|
{
|
||||||
programFile = tmp;
|
programFile = tmp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ void printSourceFileAndLine
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef darwin
|
#ifndef darwin
|
||||||
if (filename[0] == '/')
|
if (filename[0] == '/' || filename[1] == ':')
|
||||||
#else
|
#else
|
||||||
if (1)
|
if (1)
|
||||||
#endif
|
#endif
|
||||||
|
@ -175,7 +175,10 @@ void getSymbolForRaw
|
||||||
const word& address
|
const word& address
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (filename.size() && filename[0] == '/')
|
if
|
||||||
|
(
|
||||||
|
filename.size() && (filename[0] == '/' || filename[1] == ':')
|
||||||
|
)
|
||||||
{
|
{
|
||||||
string fcnt = pOpen
|
string fcnt = pOpen
|
||||||
(
|
(
|
||||||
|
@ -224,7 +227,10 @@ void error::printStack(Ostream& os)
|
||||||
string::size_type space = line.rfind(' ') + 1;
|
string::size_type space = line.rfind(' ') + 1;
|
||||||
fileName libPath = line.substr(space, line.size()-space);
|
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('-')));
|
string offsetString(line.substr(0, line.find('-')));
|
||||||
IStringStream offsetStr(offsetString);
|
IStringStream offsetStr(offsetString);
|
||||||
|
@ -268,10 +274,10 @@ void error::printStack(Ostream& os)
|
||||||
programFile = msg.substr(0, min(spacePos, bracketPos));
|
programFile = msg.substr(0, min(spacePos, bracketPos));
|
||||||
|
|
||||||
// not an absolute path
|
// not an absolute path
|
||||||
if (programFile[0] != '/')
|
if (programFile[0] != '/' && programFile[1] != ':')
|
||||||
{
|
{
|
||||||
string tmp = pOpen("which " + programFile);
|
string tmp = pOpen("which " + programFile);
|
||||||
if (tmp[0] == '/' || tmp[0] == '~')
|
if (tmp[0] == '/' || tmp[1] == ':' || tmp[0] == '~')
|
||||||
{
|
{
|
||||||
programFile = tmp;
|
programFile = tmp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName
|
||||||
fileName fName(is);
|
fileName fName(is);
|
||||||
fName.expand();
|
fName.expand();
|
||||||
|
|
||||||
if (fName.size() && fName[0] != '/')
|
if (fName.size() && fName[0] != '/' && fName[1] != ':')
|
||||||
{
|
{
|
||||||
fName = fileName(is.name()).path()/fName;
|
fName = fileName(is.name()).path()/fName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,10 @@ void Foam::argList::getRootCase()
|
||||||
casePath = cwd();
|
casePath = cwd();
|
||||||
options_.erase("case");
|
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
|
// avoid relative cases ending in '..' - makes for very ugly names
|
||||||
casePath = cwd()/casePath;
|
casePath = cwd()/casePath;
|
||||||
|
@ -177,7 +180,7 @@ void Foam::argList::getRootCase()
|
||||||
case_ = globalCase_;
|
case_ = globalCase_;
|
||||||
|
|
||||||
// Set the case and case-name as an environment variable
|
// Set the case and case-name as an environment variable
|
||||||
if (rootPath_[0] == '/')
|
if (rootPath_[0] == '/' || rootPath_[1] == ':')
|
||||||
{
|
{
|
||||||
// Absolute path - use as-is
|
// Absolute path - use as-is
|
||||||
setEnv("FOAM_CASE", rootPath_/globalCase_, true);
|
setEnv("FOAM_CASE", rootPath_/globalCase_, true);
|
||||||
|
|
|
@ -884,12 +884,18 @@ Foam::chemkinReader::chemkinReader(const dictionary& thermoDict)
|
||||||
fileName relPath = thermoDict.name().path();
|
fileName relPath = thermoDict.name().path();
|
||||||
if (relPath.size())
|
if (relPath.size())
|
||||||
{
|
{
|
||||||
if (chemkinFile.size() && chemkinFile[0] != '/')
|
if
|
||||||
|
(
|
||||||
|
chemkinFile.size() && chemkinFile[0] != '/' && chemkinFile[1] != ':'
|
||||||
|
)
|
||||||
{
|
{
|
||||||
chemkinFile = relPath/chemkinFile;
|
chemkinFile = relPath/chemkinFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thermoFile.size() && thermoFile[0] != '/')
|
if
|
||||||
|
(
|
||||||
|
thermoFile.size() && thermoFile[0] != '/' && thermoFile[1] != ':'
|
||||||
|
)
|
||||||
{
|
{
|
||||||
thermoFile = relPath/thermoFile;
|
thermoFile = relPath/thermoFile;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue