本文整理汇总了C++中fileName类的典型用法代码示例。如果您正苦于以下问题:C++ fileName类的具体用法?C++ fileName怎么用?C++ fileName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了fileName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dstFile
bool Foam::dynamicCode::createMakeFiles() const
{
// Create Make/files
if (compileFiles_.empty())
{
return false;
}
const fileName dstFile(this->codePath()/"Make/files");
// Create dir
mkDir(dstFile.path());
OFstream os(dstFile);
//Info<< "Writing to " << dstFile << endl;
if (!os.good())
{
FatalErrorInFunction
<< "Failed writing " << dstFile
<< exit(FatalError);
}
writeCommentSHA1(os);
// Write compile files
forAll(compileFiles_, fileI)
{
os.writeQuoted(compileFiles_[fileI], false) << nl;
}
示例2: WarningIn
// Create a softlink. dst should not exist. Returns true if successful.
bool Foam::ln(const fileName& src, const fileName& dst)
{
if (POSIX::debug)
{
Info<< "Create softlink from : " << src << " to " << dst
<< endl;
}
if (exists(dst))
{
WarningIn("ln(const fileName&, const fileName&)")
<< "destination " << dst << " already exists. Not linking."
<< endl;
return false;
}
if (!exists(src))
{
WarningIn("ln(const fileName&, const fileName&)")
<< "source " << src << " does not exist." << endl;
return false;
}
if (symlink(src.c_str(), dst.c_str()) == 0)
{
return true;
}
else
{
WarningIn("ln(const fileName&, const fileName&)")
<< "symlink from " << src << " to " << dst << " failed." << endl;
return false;
}
}
示例3: readSurface
void triSurf::readSurface(const fileName& fName)
{
if( fName.ext() == "fms" || fName.ext() == "FMS" )
{
readFromFMS(fName);
}
else if( fName.ext() == "ftr" || fName.ext() == "FTR" )
{
readFromFTR(fName);
}
else
{
triSurface copySurface(fName);
//- copy the points
triSurfPoints::points_.setSize(copySurface.points().size());
forAll(copySurface.points(), pI)
triSurfPoints::points_[pI] = copySurface.points()[pI];
//- copy the triangles
triSurfFacets::triangles_.setSize(copySurface.size());
forAll(copySurface, tI)
triSurfFacets::triangles_[tI] = copySurface[tI];
//- copy patches
triSurfFacets::patches_ = copySurface.patches();
}
}
示例4: base
void Foam::ensightSetWriter<Type>::write
(
const coordSet& points,
const wordList& valueSetNames,
const List<const Field<Type>*>& valueSets,
Ostream& os
) const
{
const fileName base(os.name().lessExt());
const fileName meshFile(base + ".mesh");
// Write .case file
os << "FORMAT" << nl
<< "type: ensight gold" << nl
<< nl
<< "GEOMETRY" << nl
<< "model: 1 " << meshFile.name().c_str() << nl
<< nl
<< "VARIABLE"
<< nl;
forAll(valueSetNames, setI)
{
fileName dataFile(base + ".***." + valueSetNames[setI]);
os.setf(ios_base::left);
os << pTraits<Type>::typeName
<< " per node: 1 "
<< setw(15) << valueSetNames[setI]
<< " " << dataFile.name().c_str()
<< nl;
}
示例5: ifPtr_
Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
:
ifPtr_(NULL),
compression_(IOstream::UNCOMPRESSED)
{
if (pathname.empty())
{
if (IFstream::debug)
{
Info<< "IFstreamAllocator::IFstreamAllocator(const fileName&) : "
"cannot open null file " << endl;
}
}
ifPtr_ = new ifstream(pathname.c_str());
// If the file is compressed, decompress it before reading.
if (!ifPtr_->good() && isFile(pathname + ".gz", false))
{
if (IFstream::debug)
{
Info<< "IFstreamAllocator::IFstreamAllocator(const fileName&) : "
"decompressing " << pathname + ".gz" << endl;
}
delete ifPtr_;
ifPtr_ = new igzstream((pathname + ".gz").c_str());
if (ifPtr_->good())
{
compression_ = IOstream::COMPRESSED;
}
}
}
示例6: New
Foam::autoPtr<Foam::edgeMesh> Foam::edgeMesh::New(const fileName& name)
{
word ext = name.ext();
if (ext == "gz")
{
ext = name.lessExt().ext();
}
return New(name, ext);
}
示例7: New
Foam::autoPtr<Foam::UnsortedMeshedSurface<Face>>
Foam::UnsortedMeshedSurface<Face>::New(const fileName& name)
{
word ext = name.ext();
if (ext == "gz")
{
ext = name.lessExt().ext();
}
return New(name, ext);
}
示例8: canReadType
bool Foam::UnsortedMeshedSurface<Face>::canRead
(
const fileName& name,
const bool verbose
)
{
word ext = name.ext();
if (ext == "gz")
{
ext = name.lessExt().ext();
}
return canReadType(ext, verbose);
}
示例9: read
bool Foam::edgeMesh::read(const fileName& name)
{
word ext = name.ext();
if (ext == "gz")
{
fileName unzipName = name.lessExt();
return read(unzipName, unzipName.ext());
}
else
{
return read(name, ext);
}
}
示例10: canReadType
bool Foam::edgeMesh::canRead
(
const fileName& name,
const bool verbose
)
{
word ext = name.ext();
if (ext == "gz")
{
ext = name.lessExt().ext();
}
return canReadType(ext, verbose);
}
示例11: mkDir
bool mkDir(const fileName& pathName, const mode_t mode)
{
if (pathName.empty())
{
return false;
}
bool success = ::CreateDirectory(pathName.c_str(), NULL);
if (success)
{
chMod(pathName, mode);
}
else
{
const DWORD error = ::GetLastError();
switch (error)
{
case ERROR_ALREADY_EXISTS:
{
success = true;
break;
}
case ERROR_PATH_NOT_FOUND:
{
// Part of the path does not exist so try to create it
const fileName& parentName = pathName.path();
if (parentName.size() && mkDir(parentName, mode))
{
success = mkDir(pathName, mode);
}
break;
}
}
if (!success)
{
FatalErrorIn("mkDir(const fileName&, mode_t)")
<< "Couldn't create directory: " << pathName
<< " " << MSwindows::getLastError()
<< exit(FatalError);
}
}
return success;
}
示例12: exit
void Foam::edgeMesh::write
(
const fileName& name,
const edgeMesh& mesh
)
{
if (debug)
{
Info<< "edgeMesh::write"
"(const fileName&, const edgeMesh&) : "
"writing to " << name
<< endl;
}
const word ext = name.ext();
writefileExtensionMemberFunctionTable::iterator mfIter =
writefileExtensionMemberFunctionTablePtr_->find(ext);
if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
{
FatalErrorIn
(
"MeshedSurface::write"
"(const fileName&, const MeshedSurface&)"
) << "Unknown file extension " << ext << nl << nl
<< "Valid types are :" << endl
<< writefileExtensionMemberFunctionTablePtr_->sortedToc()
<< exit(FatalError);
}
else
{
mfIter()(name, mesh);
}
}
示例13: ostr
void writePointSet
(
const bool binary,
const vtkMesh& vMesh,
const pointSet& set,
const fileName& fileName
)
{
std::ofstream ostr(fileName.c_str());
writeFuns::writeHeader
(
ostr,
binary,
set.name()
);
ostr<< "DATASET POLYDATA" << std::endl;
//------------------------------------------------------------------
//
// Write topology
//
//------------------------------------------------------------------
// Write points
ostr<< "POINTS " << set.size() << " float" << std::endl;
DynamicList<floatScalar> ptField(3*set.size());
writeFuns::insert
(
UIndirectList<point>(vMesh.mesh().points(), set.toc())(),
ptField
);
writeFuns::write(ostr, binary, ptField);
//-----------------------------------------------------------------
//
// Write data
//
//-----------------------------------------------------------------
// Write faceID
ostr
<< "POINT_DATA " << set.size() << std::endl
<< "FIELD attributes 1" << std::endl;
// Cell ids first
ostr<< "pointID 1 " << set.size() << " int" << std::endl;
labelList pointIDs(set.toc());
writeFuns::write(ostr, binary, pointIDs);
}
示例14: getRootCase
void getRootCase(fileName& casePath)
{
casePath.clean();
if (casePath.empty() || casePath == ".")
{
// handle degenerate form and '.'
casePath = cwd();
}
else if (casePath[0] != '/' && casePath.name() == "..")
{
// avoid relative cases ending in '..' - makes for very ugly names
casePath = cwd()/casePath;
casePath.clean();
}
}
示例15: dstName
//- Rename to a corresponding backup file
// If the backup file already exists, attempt with "01" .. "99" index
bool Foam::mvBak(const fileName& src, const std::string& ext)
{
if (POSIX::debug)
{
Info<< "mvBak : " << src << " to extension " << ext << endl;
}
if (exists(src, false))
{
const int maxIndex = 99;
char index[3];
for (int n = 0; n <= maxIndex; n++)
{
fileName dstName(src + "." + ext);
if (n)
{
sprintf(index, "%02d", n);
dstName += index;
}
// avoid overwriting existing files, except for the last
// possible index where we have no choice
if (!exists(dstName, false) || n == maxIndex)
{
return rename(src.c_str(), dstName.c_str()) == 0;
}
}
}
// fall-through: nothing to do
return false;
}