@@ -84,13 +84,18 @@ int vtkSEPReader::RequestData(vtkInformation *request,
84
84
{
85
85
// Replace the filename with the data file and delegate the reading of this
86
86
// raw data to the underlying vtkImageReader
87
- const char *fileName = this ->FileName ;
88
- this ->ReplaceFileName (this ->DataFile .c_str ());
87
+ char * const fileName = this ->FileName ;
88
+
89
+ // This `const_cast` is valid because the `RequestData` of
90
+ // `Superclass` does not try to modify the string pointed by
91
+ // `FileName`. (It does not modify the pointer `FileName` as well,
92
+ // but that is not why the `const_cast` is valid.)
93
+ this ->FileName = const_cast <char *>(this ->DataFile .c_str ());
89
94
90
95
int res = this ->Superclass ::RequestData (request, inputVector, outputVector);
91
96
92
- // Restore the user providen filename (the header file)
93
- this ->ReplaceFileName ( fileName) ;
97
+ // Restore the user provided filename (the header file)
98
+ this ->FileName = fileName;
94
99
return res;
95
100
}
96
101
@@ -210,24 +215,3 @@ int vtkSEPReader::ReadHeader()
210
215
211
216
return 1 ;
212
217
}
213
-
214
- // ----------------------------------------------------------------------------
215
- // Replace FileName without calling Modified()
216
- void vtkSEPReader::ReplaceFileName (const char *name)
217
- {
218
- if (this ->FileName && name && (!strcmp (this ->FileName , name)))
219
- {
220
- return ;
221
- }
222
- if (!name && !this ->FileName )
223
- {
224
- return ;
225
- }
226
- delete[] this ->FileName ;
227
- this ->FileName = nullptr ;
228
- if (name)
229
- {
230
- this ->FileName = new char [strlen (name) + 1 ];
231
- strcpy (this ->FileName , name);
232
- }
233
- }
0 commit comments