MCPcopy Create free account
hub / github.com/Kitware/VTK / DetermineFileName

Method DetermineFileName

IO/EnSight/vtkEnSightMasterServerReader.cxx:88–175  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

86
87//------------------------------------------------------------------------------
88int 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 }

Callers 2

RequestDataMethod · 0.95
RequestInformationMethod · 0.95

Calls 6

ReadNextDataLineMethod · 0.80
atMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected