OpenFOAM: Rationalised naming convention for file path
pathName, pathname -> filePath
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -50,16 +50,16 @@ int main()
|
||||
wrdList[3] = "hello3";
|
||||
wrdList[4] = "hello4.hmm";
|
||||
|
||||
fileName pathName(wrdList);
|
||||
fileName filePath(wrdList);
|
||||
|
||||
Info<< "pathName = " << pathName << nl
|
||||
<< "pathName.name() = >" << pathName.name() << "<\n"
|
||||
<< "pathName.path() = " << pathName.path() << nl
|
||||
<< "pathName.ext() = >" << pathName.ext() << "<\n"
|
||||
<< "pathName.name(true) = >" << pathName.name(true) << "<\n";
|
||||
Info<< "filePath = " << filePath << nl
|
||||
<< "filePath.name() = >" << filePath.name() << "<\n"
|
||||
<< "filePath.path() = " << filePath.path() << nl
|
||||
<< "filePath.ext() = >" << filePath.ext() << "<\n"
|
||||
<< "filePath.name(true) = >" << filePath.name(true) << "<\n";
|
||||
|
||||
Info<< "pathName.components() = " << pathName.components() << nl
|
||||
<< "pathName.component(2) = " << pathName.component(2) << nl
|
||||
Info<< "filePath.components() = " << filePath.components() << nl
|
||||
<< "filePath.component(2) = " << filePath.component(2) << nl
|
||||
<< endl;
|
||||
|
||||
// try with different combination
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -38,19 +38,19 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
void printCleaning(fileName& pathName)
|
||||
void printCleaning(fileName& filePath)
|
||||
{
|
||||
Info<< "fileName = " << pathName << nl
|
||||
<< " path() = " << pathName.path() << nl
|
||||
<< " name() = " << pathName.name() << nl
|
||||
<< " joined = " << pathName.path()/pathName.name() << nl << nl;
|
||||
Info<< "fileName = " << filePath << nl
|
||||
<< " path() = " << filePath.path() << nl
|
||||
<< " name() = " << filePath.name() << nl
|
||||
<< " joined = " << filePath.path()/filePath.name() << nl << nl;
|
||||
|
||||
pathName.clean();
|
||||
filePath.clean();
|
||||
|
||||
Info<< "cleaned = " << pathName << nl
|
||||
<< " path() = " << pathName.path() << nl
|
||||
<< " name() = " << pathName.name() << nl
|
||||
<< " joined = " << pathName.path()/pathName.name() << nl << nl;
|
||||
Info<< "cleaned = " << filePath << nl
|
||||
<< " path() = " << filePath.path() << nl
|
||||
<< " name() = " << filePath.name() << nl
|
||||
<< " joined = " << filePath.path()/filePath.name() << nl << nl;
|
||||
|
||||
IOobject::writeDivider(Info);
|
||||
}
|
||||
@ -74,8 +74,8 @@ int main(int argc, char *argv[])
|
||||
args.printUsage();
|
||||
}
|
||||
|
||||
fileName pathName;
|
||||
if (args.optionReadIfPresent("case", pathName))
|
||||
fileName filePath;
|
||||
if (args.optionReadIfPresent("case", filePath))
|
||||
{
|
||||
Info<< nl
|
||||
<< "-case" << nl
|
||||
@ -86,18 +86,18 @@ int main(int argc, char *argv[])
|
||||
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
|
||||
<< endl;
|
||||
|
||||
printCleaning(pathName);
|
||||
printCleaning(filePath);
|
||||
}
|
||||
|
||||
for (label argI=1; argI < args.size(); ++argI)
|
||||
{
|
||||
pathName = args[argI];
|
||||
printCleaning(pathName);
|
||||
filePath = args[argI];
|
||||
printCleaning(filePath);
|
||||
}
|
||||
|
||||
if (args.optionFound("istream"))
|
||||
{
|
||||
args.optionLookup("istream")() >> pathName;
|
||||
args.optionLookup("istream")() >> filePath;
|
||||
|
||||
Info<< nl
|
||||
<< "-case" << nl
|
||||
@ -108,7 +108,7 @@ int main(int argc, char *argv[])
|
||||
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
|
||||
<< endl;
|
||||
|
||||
printCleaning(pathName);
|
||||
printCleaning(filePath);
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -287,11 +287,11 @@ bool Foam::chDir(const fileName& dir)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
bool Foam::mkDir(const fileName& filePath, mode_t mode)
|
||||
{
|
||||
if (POSIX::debug)
|
||||
{
|
||||
Pout<< FUNCTION_NAME << " : pathName:" << pathName << " mode:" << mode
|
||||
Pout<< FUNCTION_NAME << " : filePath:" << filePath << " mode:" << mode
|
||||
<< endl;
|
||||
if ((POSIX::debug & 2) && !Pstream::master())
|
||||
{
|
||||
@ -300,13 +300,13 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
}
|
||||
|
||||
// Empty names are meaningless
|
||||
if (pathName.empty())
|
||||
if (filePath.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Construct instance path directory if does not exist
|
||||
if (::mkdir(pathName.c_str(), mode) == 0)
|
||||
if (::mkdir(filePath.c_str(), mode) == 0)
|
||||
{
|
||||
// Directory made OK so return true
|
||||
return true;
|
||||
@ -318,7 +318,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
case EPERM:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "The filesystem containing " << pathName
|
||||
<< "The filesystem containing " << filePath
|
||||
<< " does not support the creation of directories."
|
||||
<< exit(FatalError);
|
||||
|
||||
@ -334,7 +334,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
case EFAULT:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "" << pathName
|
||||
<< "" << filePath
|
||||
<< " points outside your accessible address space."
|
||||
<< exit(FatalError);
|
||||
|
||||
@ -346,7 +346,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
FatalErrorInFunction
|
||||
<< "The parent directory does not allow write "
|
||||
"permission to the process,"<< nl
|
||||
<< "or one of the directories in " << pathName
|
||||
<< "or one of the directories in " << filePath
|
||||
<< " did not allow search (execute) permission."
|
||||
<< exit(FatalError);
|
||||
|
||||
@ -356,7 +356,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
case ENAMETOOLONG:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "" << pathName << " is too long."
|
||||
<< "" << filePath << " is too long."
|
||||
<< exit(FatalError);
|
||||
|
||||
return false;
|
||||
@ -365,14 +365,14 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
case ENOENT:
|
||||
{
|
||||
// Part of the path does not exist so try to create it
|
||||
if (pathName.path().size() && mkDir(pathName.path(), mode))
|
||||
if (filePath.path().size() && mkDir(filePath.path(), mode))
|
||||
{
|
||||
return mkDir(pathName, mode);
|
||||
return mkDir(filePath, mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Couldn't create directory " << pathName
|
||||
<< "Couldn't create directory " << filePath
|
||||
<< exit(FatalError);
|
||||
|
||||
return false;
|
||||
@ -382,7 +382,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
case ENOTDIR:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "A component used as a directory in " << pathName
|
||||
<< "A component used as a directory in " << filePath
|
||||
<< " is not, in fact, a directory."
|
||||
<< exit(FatalError);
|
||||
|
||||
@ -393,7 +393,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Insufficient kernel memory was available to make "
|
||||
"directory " << pathName << '.'
|
||||
"directory " << filePath << '.'
|
||||
<< exit(FatalError);
|
||||
|
||||
return false;
|
||||
@ -402,7 +402,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
case EROFS:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "" << pathName
|
||||
<< "" << filePath
|
||||
<< " refers to a file on a read-only filesystem."
|
||||
<< exit(FatalError);
|
||||
|
||||
@ -413,7 +413,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Too many symbolic links were encountered in resolving "
|
||||
<< pathName << '.'
|
||||
<< filePath << '.'
|
||||
<< exit(FatalError);
|
||||
|
||||
return false;
|
||||
@ -422,7 +422,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
case ENOSPC:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "The device containing " << pathName
|
||||
<< "The device containing " << filePath
|
||||
<< " has no room for the new directory or "
|
||||
<< "the user's disk quota is exhausted."
|
||||
<< exit(FatalError);
|
||||
@ -433,7 +433,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Couldn't create directory " << pathName
|
||||
<< "Couldn't create directory " << filePath
|
||||
<< exit(FatalError);
|
||||
|
||||
return false;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,12 +37,12 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
|
||||
Foam::IFstreamAllocator::IFstreamAllocator(const fileName& filePath)
|
||||
:
|
||||
ifPtr_(nullptr),
|
||||
compression_(IOstream::UNCOMPRESSED)
|
||||
{
|
||||
if (pathname.empty())
|
||||
if (filePath.empty())
|
||||
{
|
||||
if (IFstream::debug)
|
||||
{
|
||||
@ -50,32 +50,32 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
|
||||
}
|
||||
}
|
||||
|
||||
ifPtr_ = new ifstream(pathname.c_str());
|
||||
ifPtr_ = new ifstream(filePath.c_str());
|
||||
|
||||
// If the file is compressed, decompress it before reading.
|
||||
if (!ifPtr_->good())
|
||||
{
|
||||
if (isFile(pathname + ".gz", false, false))
|
||||
if (isFile(filePath + ".gz", false, false))
|
||||
{
|
||||
delete ifPtr_;
|
||||
|
||||
if (IFstream::debug)
|
||||
{
|
||||
InfoInFunction << "Decompressing " << pathname + ".gz" << endl;
|
||||
InfoInFunction << "Decompressing " << filePath + ".gz" << endl;
|
||||
}
|
||||
|
||||
ifPtr_ = new igzstream((pathname + ".gz").c_str());
|
||||
ifPtr_ = new igzstream((filePath + ".gz").c_str());
|
||||
|
||||
if (ifPtr_->good())
|
||||
{
|
||||
compression_ = IOstream::COMPRESSED;
|
||||
}
|
||||
}
|
||||
else if (isFile(pathname + ".orig", false, false))
|
||||
else if (isFile(filePath + ".orig", false, false))
|
||||
{
|
||||
delete ifPtr_;
|
||||
|
||||
ifPtr_ = new ifstream((pathname + ".orig").c_str());
|
||||
ifPtr_ = new ifstream((filePath + ".orig").c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,12 +91,12 @@ Foam::IFstreamAllocator::~IFstreamAllocator()
|
||||
|
||||
Foam::IFstream::IFstream
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
streamFormat format,
|
||||
versionNumber version
|
||||
)
|
||||
:
|
||||
IFstreamAllocator(pathname),
|
||||
IFstreamAllocator(filePath),
|
||||
ISstream
|
||||
(
|
||||
*ifPtr_,
|
||||
@ -105,7 +105,7 @@ Foam::IFstream::IFstream
|
||||
version,
|
||||
IFstreamAllocator::compression_
|
||||
),
|
||||
pathname_(pathname)
|
||||
filePath_(filePath)
|
||||
{
|
||||
setClosed();
|
||||
|
||||
@ -175,7 +175,7 @@ Foam::IFstream& Foam::IFstream::operator()() const
|
||||
if (!good())
|
||||
{
|
||||
// also checks variants
|
||||
if (isFile(pathname_, true, true))
|
||||
if (isFile(filePath_, true, true))
|
||||
{
|
||||
check("IFstream::operator()");
|
||||
FatalIOError.exit();
|
||||
@ -183,7 +183,7 @@ Foam::IFstream& Foam::IFstream::operator()() const
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction(*this)
|
||||
<< "file " << pathname_ << " does not exist"
|
||||
<< "file " << filePath_ << " does not exist"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -66,8 +66,8 @@ class IFstreamAllocator
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from pathname
|
||||
IFstreamAllocator(const fileName& pathname);
|
||||
//- Construct from filePath
|
||||
IFstreamAllocator(const fileName& filePath);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -86,7 +86,7 @@ class IFstream
|
||||
{
|
||||
// Private Data
|
||||
|
||||
fileName pathname_;
|
||||
fileName filePath_;
|
||||
|
||||
public:
|
||||
|
||||
@ -96,10 +96,10 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from pathname
|
||||
//- Construct from filePath
|
||||
IFstream
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
);
|
||||
@ -116,13 +116,13 @@ public:
|
||||
//- Return the name of the stream
|
||||
const fileName& name() const
|
||||
{
|
||||
return pathname_;
|
||||
return filePath_;
|
||||
}
|
||||
|
||||
//- Return non-const access to the name of the stream
|
||||
fileName& name()
|
||||
{
|
||||
return pathname_;
|
||||
return filePath_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -39,14 +39,14 @@ namespace Foam
|
||||
|
||||
Foam::OFstreamAllocator::OFstreamAllocator
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
IOstream::compressionType compression,
|
||||
const bool append
|
||||
)
|
||||
:
|
||||
ofPtr_(nullptr)
|
||||
{
|
||||
if (pathname.empty())
|
||||
if (filePath.empty())
|
||||
{
|
||||
if (OFstream::debug)
|
||||
{
|
||||
@ -62,43 +62,43 @@ Foam::OFstreamAllocator::OFstreamAllocator
|
||||
if (compression == IOstream::COMPRESSED)
|
||||
{
|
||||
// Get identically named uncompressed version out of the way
|
||||
fileType pathType = Foam::type(pathname, false, false);
|
||||
fileType pathType = Foam::type(filePath, false, false);
|
||||
if (pathType == fileType::file || pathType == fileType::link)
|
||||
{
|
||||
rm(pathname);
|
||||
rm(filePath);
|
||||
}
|
||||
fileName gzPathName(pathname + ".gz");
|
||||
fileName gzfilePath(filePath + ".gz");
|
||||
|
||||
if (!append && Foam::type(gzPathName) == fileType::link)
|
||||
if (!append && Foam::type(gzfilePath) == fileType::link)
|
||||
{
|
||||
// Disallow writing into softlink to avoid any problems with
|
||||
// e.g. softlinked initial fields
|
||||
rm(gzPathName);
|
||||
rm(gzfilePath);
|
||||
}
|
||||
|
||||
ofPtr_ = new ogzstream(gzPathName.c_str(), mode);
|
||||
ofPtr_ = new ogzstream(gzfilePath.c_str(), mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
// get identically named compressed version out of the way
|
||||
fileName gzPathName(pathname + ".gz");
|
||||
fileType gzType = Foam::type(gzPathName, false, false);
|
||||
fileName gzfilePath(filePath + ".gz");
|
||||
fileType gzType = Foam::type(gzfilePath, false, false);
|
||||
if (gzType == fileType::file || gzType == fileType::link)
|
||||
{
|
||||
rm(gzPathName);
|
||||
rm(gzfilePath);
|
||||
}
|
||||
if
|
||||
(
|
||||
!append
|
||||
&& Foam::type(pathname, false, false) == fileType::link
|
||||
&& Foam::type(filePath, false, false) == fileType::link
|
||||
)
|
||||
{
|
||||
// Disallow writing into softlink to avoid any problems with
|
||||
// e.g. softlinked initial fields
|
||||
rm(pathname);
|
||||
rm(filePath);
|
||||
}
|
||||
|
||||
ofPtr_ = new ofstream(pathname.c_str(), mode);
|
||||
ofPtr_ = new ofstream(filePath.c_str(), mode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,16 +113,16 @@ Foam::OFstreamAllocator::~OFstreamAllocator()
|
||||
|
||||
Foam::OFstream::OFstream
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
streamFormat format,
|
||||
versionNumber version,
|
||||
compressionType compression,
|
||||
const bool append
|
||||
)
|
||||
:
|
||||
OFstreamAllocator(pathname, compression, append),
|
||||
OFstreamAllocator(filePath, compression, append),
|
||||
OSstream(*ofPtr_, "OFstream.sinkFile_", format, version, compression),
|
||||
pathname_(pathname)
|
||||
filePath_(filePath)
|
||||
{
|
||||
setClosed();
|
||||
setState(ofPtr_->rdstate());
|
||||
@ -132,7 +132,7 @@ Foam::OFstream::OFstream
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction
|
||||
<< "Could not open file " << pathname
|
||||
<< "Could not open file " << filePath
|
||||
<< "for input\n"
|
||||
"in stream " << info() << Foam::endl;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -62,10 +62,10 @@ class OFstreamAllocator
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from pathname
|
||||
//- Construct from filePath
|
||||
OFstreamAllocator
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
IOstream::compressionType compression=IOstream::UNCOMPRESSED,
|
||||
const bool append = false
|
||||
);
|
||||
@ -87,7 +87,7 @@ class OFstream
|
||||
{
|
||||
// Private Data
|
||||
|
||||
fileName pathname_;
|
||||
fileName filePath_;
|
||||
|
||||
|
||||
public:
|
||||
@ -98,10 +98,10 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from pathname
|
||||
//- Construct from filePath
|
||||
OFstream
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
compressionType compression=UNCOMPRESSED,
|
||||
@ -120,13 +120,13 @@ public:
|
||||
//- Return the name of the stream
|
||||
const fileName& name() const
|
||||
{
|
||||
return pathname_;
|
||||
return filePath_;
|
||||
}
|
||||
|
||||
//- Return non-const access to the name of the stream
|
||||
fileName& name()
|
||||
{
|
||||
return pathname_;
|
||||
return filePath_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -70,7 +70,7 @@ void Foam::masterOFstream::checkWrite
|
||||
|
||||
Foam::masterOFstream::masterOFstream
|
||||
(
|
||||
const fileName& pathName,
|
||||
const fileName& filePath,
|
||||
streamFormat format,
|
||||
versionNumber version,
|
||||
compressionType compression,
|
||||
@ -79,7 +79,7 @@ Foam::masterOFstream::masterOFstream
|
||||
)
|
||||
:
|
||||
OStringStream(format, version),
|
||||
pathName_(pathName),
|
||||
filePath_(filePath),
|
||||
compression_(compression),
|
||||
append_(append),
|
||||
write_(write)
|
||||
@ -93,7 +93,7 @@ Foam::masterOFstream::~masterOFstream()
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
List<fileName> filePaths(Pstream::nProcs());
|
||||
filePaths[Pstream::myProcNo()] = pathName_;
|
||||
filePaths[Pstream::myProcNo()] = filePath_;
|
||||
Pstream::gatherList(filePaths);
|
||||
|
||||
bool uniform =
|
||||
@ -108,7 +108,7 @@ Foam::masterOFstream::~masterOFstream()
|
||||
{
|
||||
if (Pstream::master() && write_)
|
||||
{
|
||||
checkWrite(pathName_, str());
|
||||
checkWrite(filePath_, str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -161,7 +161,7 @@ Foam::masterOFstream::~masterOFstream()
|
||||
}
|
||||
else
|
||||
{
|
||||
checkWrite(pathName_, str());
|
||||
checkWrite(filePath_, str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -52,7 +52,7 @@ class masterOFstream
|
||||
{
|
||||
// Private Data
|
||||
|
||||
const fileName pathName_;
|
||||
const fileName filePath_;
|
||||
|
||||
const IOstream::compressionType compression_;
|
||||
|
||||
@ -75,7 +75,7 @@ public:
|
||||
//- Construct and set stream status
|
||||
masterOFstream
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
compressionType compression=UNCOMPRESSED,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -215,7 +215,7 @@ void* Foam::OFstreamCollator::writeAll(void *threadarg)
|
||||
(
|
||||
ptr->comm_,
|
||||
ptr->typeName_,
|
||||
ptr->pathName_,
|
||||
ptr->filePath_,
|
||||
ptr->data_,
|
||||
ptr->sizes_,
|
||||
slaveData,
|
||||
@ -226,8 +226,8 @@ void* Foam::OFstreamCollator::writeAll(void *threadarg)
|
||||
);
|
||||
if (!ok)
|
||||
{
|
||||
FatalIOErrorInFunction(ptr->pathName_)
|
||||
<< "Failed writing " << ptr->pathName_
|
||||
FatalIOErrorInFunction(ptr->filePath_)
|
||||
<< "Failed writing " << ptr->filePath_
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ class OFstreamCollator
|
||||
|
||||
const label comm_;
|
||||
const word typeName_;
|
||||
const fileName pathName_;
|
||||
const fileName filePath_;
|
||||
const string data_;
|
||||
const labelList sizes_;
|
||||
PtrList<List<char>> slaveData_;
|
||||
@ -101,7 +101,7 @@ class OFstreamCollator
|
||||
:
|
||||
comm_(comm),
|
||||
typeName_(typeName),
|
||||
pathName_(filePath),
|
||||
filePath_(filePath),
|
||||
data_(data),
|
||||
sizes_(sizes),
|
||||
slaveData_(0),
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::threadedCollatedOFstream::threadedCollatedOFstream
|
||||
:
|
||||
OStringStream(format, version),
|
||||
writer_(writer),
|
||||
pathName_(filePath),
|
||||
filePath_(filePath),
|
||||
compression_(compression),
|
||||
useThread_(useThread)
|
||||
{}
|
||||
@ -54,7 +54,7 @@ Foam::threadedCollatedOFstream::~threadedCollatedOFstream()
|
||||
writer_.write
|
||||
(
|
||||
decomposedBlockData::typeName,
|
||||
pathName_,
|
||||
filePath_,
|
||||
str(),
|
||||
IOstream::BINARY,
|
||||
version(),
|
||||
|
||||
@ -56,7 +56,7 @@ class threadedCollatedOFstream
|
||||
|
||||
OFstreamCollator& writer_;
|
||||
|
||||
const fileName pathName_;
|
||||
const fileName filePath_;
|
||||
|
||||
const IOstream::compressionType compression_;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -247,7 +247,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Assemble words and fileNames as pathnames by adding a '/' separator
|
||||
//- Assemble words and fileNames as filePaths by adding a '/' separator
|
||||
fileName operator/(const string&, const string&);
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -83,11 +83,11 @@ Foam::label Foam::ensightFile::subDirWidth()
|
||||
|
||||
Foam::ensightFile::ensightFile
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
IOstream::streamFormat format
|
||||
)
|
||||
:
|
||||
OFstream(pathname, format)
|
||||
OFstream(filePath, format)
|
||||
{
|
||||
// ascii formatting specs
|
||||
setf
|
||||
|
||||
@ -68,10 +68,10 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from pathname
|
||||
//- Construct from filePath
|
||||
ensightFile
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
IOstream::streamFormat format=IOstream::BINARY
|
||||
);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,11 +29,11 @@ License
|
||||
|
||||
Foam::ensightGeoFile::ensightGeoFile
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
IOstream::streamFormat format
|
||||
)
|
||||
:
|
||||
ensightFile(pathname, format)
|
||||
ensightFile(filePath, format)
|
||||
{
|
||||
writeBinaryHeader();
|
||||
write("Ensight Geometry File"); newline();
|
||||
|
||||
@ -51,10 +51,10 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from pathname
|
||||
//- Construct from filePath
|
||||
ensightGeoFile
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
IOstream::streamFormat format=IOstream::BINARY
|
||||
);
|
||||
|
||||
|
||||
@ -58,13 +58,13 @@ void Foam::OBJstream::writeAndCheck(const char c)
|
||||
|
||||
Foam::OBJstream::OBJstream
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
streamFormat format,
|
||||
versionNumber version,
|
||||
compressionType compression
|
||||
)
|
||||
:
|
||||
OFstream(pathname, format, version, compression),
|
||||
OFstream(filePath, format, version, compression),
|
||||
startOfLine_(true),
|
||||
nVertices_(0)
|
||||
{}
|
||||
|
||||
@ -74,10 +74,10 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from pathname
|
||||
//- Construct from filePath
|
||||
OBJstream
|
||||
(
|
||||
const fileName& pathname,
|
||||
const fileName& filePath,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
compressionType compression=UNCOMPRESSED
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration | Website: https://openfoam.org
|
||||
# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
# \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
@ -63,11 +63,11 @@ echo >> Make/files
|
||||
for file in `find . -name "*.[cCylLfF]" -type f -print`
|
||||
do
|
||||
fileName=`echo ${file##*/}`
|
||||
pathName=`echo ${file%/*} | sed 's%^\.%%' | sed 's%^/%%' | $dirToString`
|
||||
filePath=`echo ${file%/*} | sed 's%^\.%%' | sed 's%^/%%' | $dirToString`
|
||||
|
||||
if [ -n "$pathName" ]
|
||||
if [ -n "$filePath" ]
|
||||
then
|
||||
echo '$('$pathName')/'$fileName >> Make/files
|
||||
echo '$('$filePath')/'$fileName >> Make/files
|
||||
else
|
||||
echo $fileName >> Make/files
|
||||
fi
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -94,11 +94,11 @@ const char* currentPath = NULL;
|
||||
|
||||
void nextFile(const char* fileName);
|
||||
int lookUp(struct HashEntry** hashTable, const char* p);
|
||||
void addFile(char* pathName);
|
||||
void openFile(const char* pathName);
|
||||
void addFile(char* filePath);
|
||||
void openFile(const char* filePath);
|
||||
char* strRep(char* str, struct searchReplace* sr);
|
||||
char* substitutePath(char* pathName);
|
||||
void printFile(FILE* file, const char* pathName);
|
||||
char* substitutePath(char* filePath);
|
||||
void printFile(FILE* file, const char* filePath);
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
@ -285,17 +285,17 @@ int main(int argc, char* argv[])
|
||||
/* Add a directory name to the file name */
|
||||
char* addDirectoryName(const char* dirName, const char* fileName)
|
||||
{
|
||||
char* pathName = (char*)malloc(strlen(dirName) + strlen(fileName) + 2);
|
||||
strcpy(pathName, dirName);
|
||||
char* filePath = (char*)malloc(strlen(dirName) + strlen(fileName) + 2);
|
||||
strcpy(filePath, dirName);
|
||||
|
||||
if (dirName[strlen(dirName)-1] != '/')
|
||||
{
|
||||
strcat(pathName, "/");
|
||||
strcat(filePath, "/");
|
||||
}
|
||||
|
||||
strcat(pathName, fileName);
|
||||
strcat(filePath, fileName);
|
||||
|
||||
return pathName;
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
||||
@ -317,17 +317,17 @@ void nextFile(const char* fileName)
|
||||
int i;
|
||||
for (i = 0; i < nDirectories; i++)
|
||||
{
|
||||
char* pathName = addDirectoryName(directories[i], fileName);
|
||||
char* filePath = addDirectoryName(directories[i], fileName);
|
||||
|
||||
if (access(pathName, R_OK ) != -1)
|
||||
if (access(filePath, R_OK ) != -1)
|
||||
{
|
||||
addFile(pathName);
|
||||
addFile(filePath);
|
||||
currentPath = directories[i];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
free(pathName);
|
||||
free(filePath);
|
||||
}
|
||||
|
||||
if (nDirectories == 0)
|
||||
@ -393,7 +393,7 @@ int lookUp(struct HashEntry** hashTable, const char* p)
|
||||
|
||||
|
||||
/* Add file to list */
|
||||
void addFile(char* pathName)
|
||||
void addFile(char* filePath)
|
||||
{
|
||||
if (nFiles == maxNfiles - 1)
|
||||
{
|
||||
@ -401,20 +401,20 @@ void addFile(char* pathName)
|
||||
files = (char**)realloc(files, sizeof(char*)*maxNfiles);
|
||||
}
|
||||
|
||||
files[nFiles++] = pathName;
|
||||
files[nFiles++] = filePath;
|
||||
}
|
||||
|
||||
|
||||
/* Open file and set yyin */
|
||||
void openFile(const char* pathName)
|
||||
void openFile(const char* filePath)
|
||||
{
|
||||
if (!(yyin = fopen(pathName, "r")))
|
||||
if (!(yyin = fopen(filePath, "r")))
|
||||
{
|
||||
fprintf
|
||||
(
|
||||
stderr,
|
||||
"could not open file %s for source file %s due to %s\n",
|
||||
pathName, sourceFile, strerror(errno)
|
||||
filePath, sourceFile, strerror(errno)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -455,25 +455,25 @@ char* strRep(char* str, struct searchReplace* sr)
|
||||
|
||||
|
||||
/* Substitute path components with command-line replacements */
|
||||
char* substitutePath(char* pathName)
|
||||
char* substitutePath(char* filePath)
|
||||
{
|
||||
if (nReplacements)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nReplacements; i++)
|
||||
{
|
||||
pathName = strRep(pathName, &replacements[i]);
|
||||
filePath = strRep(filePath, &replacements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return pathName;
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
||||
/* Print file path to the dependencies file */
|
||||
void printFile(FILE* file, const char* pathName)
|
||||
void printFile(FILE* file, const char* filePath)
|
||||
{
|
||||
fprintf(file, "%s \\\n", pathName);
|
||||
fprintf(file, "%s \\\n", filePath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user