void printCleaning(fileName& pathName) { Info<< "fileName = " << pathName << nl << " path() = " << pathName.path() << nl << " name() = " << pathName.name() << nl << " joined = " << pathName.path()/pathName.name() << nl << nl; pathName.clean(); Info<< "cleaned = " << pathName << nl << " path() = " << pathName.path() << nl << " name() = " << pathName.name() << nl << " joined = " << pathName.path()/pathName.name() << nl << nl; IOobject::writeDivider(Info); }
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; }
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; }
void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::checkTable() { // Initialise if (startSampleTime_ == -1 && endSampleTime_ == -1) { const polyMesh& pMesh = this->patch().boundaryMesh().mesh()(); // Read the initial point position pointField meshPts; if (pMesh.pointsInstance() == pMesh.facesInstance()) { meshPts = pointField(pMesh.points(), this->patch().meshPoints()); } else { // Load points from facesInstance if (debug) { Info<< "Reloading points0 from " << pMesh.facesInstance() << endl; } pointIOField points0 ( IOobject ( "points", pMesh.facesInstance(), polyMesh::meshSubDir, pMesh, IOobject::MUST_READ, IOobject::NO_WRITE, false ) ); meshPts = pointField(points0, this->patch().meshPoints()); } pointIOField samplePoints ( IOobject ( "points", this->db().time().constant(), "boundaryData"/this->patch().name(), this->db(), IOobject::MUST_READ, IOobject::AUTO_WRITE, false ) ); // tbd: run-time selection bool nearestOnly = ( !mapMethod_.empty() && mapMethod_ != "planarInterpolation" ); // Allocate the interpolator mapperPtr_.reset ( new pointToPointPlanarInterpolation ( samplePoints, meshPts, perturb_, nearestOnly ) ); // Read the times for which data is available const fileName samplePointsFile = samplePoints.filePath(); const fileName samplePointsDir = samplePointsFile.path(); sampleTimes_ = Time::findTimes(samplePointsDir); if (debug) { Info<< "timeVaryingMappedFixedValuePointPatchField : In directory " << samplePointsDir << " found times " << pointToPointPlanarInterpolation::timeNames(sampleTimes_) << endl; } } // Find current time in sampleTimes label lo = -1; label hi = -1; bool foundTime = mapperPtr_().findTime ( sampleTimes_, startSampleTime_, this->db().time().value(), lo, hi ); if (!foundTime) { FatalErrorIn ( "timeVaryingMappedFixedValuePointPatchField<Type>::checkTable" ) << "Cannot find starting sampling values for current time " << this->db().time().value() << nl << "Have sampling values for times " << pointToPointPlanarInterpolation::timeNames(sampleTimes_) << nl << "In directory " << this->db().time().constant()/"boundaryData"/this->patch().name() << "\n on patch " << this->patch().name() << " of field " << fieldTableName_ << exit(FatalError); } // Update sampled data fields. if (lo != startSampleTime_) { startSampleTime_ = lo; if (startSampleTime_ == endSampleTime_) { // No need to reread since are end values if (debug) { Pout<< "checkTable : Setting startValues to (already read) " << "boundaryData" /this->patch().name() /sampleTimes_[startSampleTime_].name() << endl; } startSampledValues_ = endSampledValues_; startAverage_ = endAverage_; } else { if (debug) { Pout<< "checkTable : Reading startValues from " << "boundaryData" /this->patch().name() /sampleTimes_[lo].name() << endl; } // Reread values and interpolate AverageIOField<Type> vals ( IOobject ( fieldTableName_, this->db().time().constant(), "boundaryData" /this->patch().name() /sampleTimes_[startSampleTime_].name(), this->db(), IOobject::MUST_READ, IOobject::AUTO_WRITE, false ) ); if (vals.size() != mapperPtr_().sourceSize()) { FatalErrorIn ( "timeVaryingMappedFixedValuePointPatchField<Type>::" "checkTable()" ) << "Number of values (" << vals.size() << ") differs from the number of points (" << mapperPtr_().sourceSize() << ") in file " << vals.objectPath() << exit(FatalError); } startAverage_ = vals.average(); startSampledValues_ = mapperPtr_().interpolate(vals); } } if (hi != endSampleTime_) { endSampleTime_ = hi; if (endSampleTime_ == -1) { // endTime no longer valid. Might as well clear endValues. if (debug) { Pout<< "checkTable : Clearing endValues" << endl; } endSampledValues_.clear(); } else { if (debug) { Pout<< "checkTable : Reading endValues from " << "boundaryData" /this->patch().name() /sampleTimes_[endSampleTime_].name() << endl; } // Reread values and interpolate AverageIOField<Type> vals ( IOobject ( fieldTableName_, this->db().time().constant(), "boundaryData" /this->patch().name() /sampleTimes_[endSampleTime_].name(), this->db(), IOobject::MUST_READ, IOobject::AUTO_WRITE, false ) ); if (vals.size() != mapperPtr_().sourceSize()) { FatalErrorIn ( "timeVaryingMappedFixedValuePointPatchField<Type>::" "checkTable()" ) << "Number of values (" << vals.size() << ") differs from the number of points (" << mapperPtr_().sourceSize() << ") in file " << vals.objectPath() << exit(FatalError); } endAverage_ = vals.average(); endSampledValues_ = mapperPtr_().interpolate(vals); } } }
bool Foam::mkDir(const fileName& pathName, mode_t mode) { // empty names are meaningless if (pathName.empty()) { return false; } // Construct instance path directory if does not exist if (::mkdir(pathName.c_str(), mode) == 0) { // Directory made OK so return true return true; } else { switch (errno) { case EPERM: { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "The filesystem containing " << pathName << " does not support the creation of directories." << exit(FatalError); return false; } case EEXIST: { // Directory already exists so simply return true return true; } case EFAULT: { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "" << pathName << " points outside your accessible address space." << exit(FatalError); return false; } case EACCES: { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "The parent directory does not allow write " "permission to the process,"<< nl << "or one of the directories in " << pathName << " did not allow search (execute) permission." << exit(FatalError); return false; } case ENAMETOOLONG: { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "" << pathName << " is too long." << exit(FatalError); return false; } case ENOENT: { // Part of the path does not exist so try to create it if (pathName.path().size() && mkDir(pathName.path(), mode)) { return mkDir(pathName, mode); } else { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "Couldn't create directory " << pathName << exit(FatalError); return false; } } case ENOTDIR: { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "A component used as a directory in " << pathName << " is not, in fact, a directory." << exit(FatalError); return false; } case ENOMEM: { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "Insufficient kernel memory was available to make " "directory " << pathName << '.' << exit(FatalError); return false; } case EROFS: { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "" << pathName << " refers to a file on a read-only filesystem." << exit(FatalError); return false; } case ELOOP: { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "Too many symbolic links were encountered in resolving " << pathName << '.' << exit(FatalError); return false; } case ENOSPC: { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "The device containing " << pathName << " has no room for the new directory or " << "the user's disk quota is exhausted." << exit(FatalError); return false; } default: { FatalErrorIn("Foam::mkDir(const fileName&, mode_t)") << "Couldn't create directory " << pathName << exit(FatalError); return false; } } } }