------------------------------------------------------------------------------
| 86 | |
| 87 | //------------------------------------------------------------------------------ |
| 88 | int vtkEnSightMasterServerReader::DetermineFileName(int piece) |
| 89 | { |
| 90 | if (!this->CaseFileName) |
| 91 | { |
| 92 | vtkErrorMacro("A case file name must be specified."); |
| 93 | return VTK_ERROR; |
| 94 | } |
| 95 | std::string sfilename; |
| 96 | if (this->FilePath) |
| 97 | { |
| 98 | sfilename = this->FilePath; |
| 99 | if (sfilename.at(sfilename.length() - 1) != '/') |
| 100 | { |
| 101 | sfilename += "/"; |
| 102 | } |
| 103 | sfilename += this->CaseFileName; |
| 104 | vtkDebugMacro("full path to case file: " << sfilename); |
| 105 | } |
| 106 | else |
| 107 | { |
| 108 | sfilename = this->CaseFileName; |
| 109 | } |
| 110 | |
| 111 | this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); |
| 112 | if (this->IS->fail()) |
| 113 | { |
| 114 | vtkErrorMacro("Unable to open file: " << sfilename); |
| 115 | delete this->IS; |
| 116 | this->IS = nullptr; |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | char result[1024]; |
| 121 | |
| 122 | int servers = 0; |
| 123 | int numberservers = 0; |
| 124 | int currentserver = 0; |
| 125 | |
| 126 | while (this->ReadNextDataLine(result)) |
| 127 | { |
| 128 | if (strcmp(result, "FORMAT") == 0) |
| 129 | { |
| 130 | // Format |
| 131 | } |
| 132 | else if (strcmp(result, "SERVERS") == 0) |
| 133 | { |
| 134 | servers = 1; |
| 135 | } |
| 136 | else if (servers && vtkEnSightMasterServerReaderStartsWith(result, "number of servers:")) |
| 137 | { |
| 138 | auto resultServers = vtk::scan<int>(std::string_view(result), "number of servers: {:d}"); |
| 139 | numberservers = resultServers->value(); |
| 140 | if (!numberservers) |
| 141 | { |
| 142 | vtkErrorMacro("The case file is corrupted"); |
| 143 | break; |
| 144 | } |
| 145 | } |
no test coverage detected