| 29 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // |
| 30 | |
| 31 | bool Foam::IOobject::readHeader(Istream& is) |
| 32 | { |
| 33 | if (IOobject::debug) |
| 34 | { |
| 35 | InfoInFunction << "Reading header for file " << is.name() << endl; |
| 36 | } |
| 37 | |
| 38 | // Check Istream not already bad |
| 39 | if (!is.good()) |
| 40 | { |
| 41 | if (rOpt_ == MUST_READ || rOpt_ == MUST_READ_IF_MODIFIED) |
| 42 | { |
| 43 | FatalIOErrorInFunction(is) |
| 44 | << " stream not open for reading essential object from file " |
| 45 | << is.name() |
| 46 | << exit(FatalIOError); |
| 47 | } |
| 48 | |
| 49 | if (IOobject::debug) |
| 50 | { |
| 51 | SeriousIOErrorInFunction(is) |
| 52 | << " stream not open for reading from file " |
| 53 | << is.name() << endl; |
| 54 | } |
| 55 | |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | token firstToken(is); |
| 60 | |
| 61 | if |
| 62 | ( |
| 63 | is.good() |
| 64 | && firstToken.isWord() |
| 65 | && firstToken.wordToken() == "FoamFile" |
| 66 | ) |
| 67 | { |
| 68 | dictionary headerDict(is); |
| 69 | |
| 70 | is.version(headerDict.lookup("version")); |
| 71 | is.format(headerDict.lookup("format")); |
| 72 | headerClassName_ = word(headerDict.lookup("class")); |
| 73 | |
| 74 | const word headerObject(headerDict.lookup("object")); |
| 75 | if (IOobject::debug && headerObject != name()) |
| 76 | { |
| 77 | IOWarningInFunction(is) |
| 78 | << " object renamed from " |
| 79 | << name() << " to " << headerObject |
| 80 | << " for file " << is.name() << endl; |
| 81 | } |
| 82 | |
| 83 | // The note entry is optional |
| 84 | headerDict.readIfPresent("note", note_); |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | IOWarningInFunction(is) |
no test coverage detected