From 8675c0cd01bacafbeb815f70ac140aedf28e0bab Mon Sep 17 00:00:00 2001 From: Todd Martin <nztoddler@yahoo.com> Date: Sat, 26 Oct 2019 16:14:12 +1300 Subject: [PATCH] Utilise KWSYS ifstream and ofstream to properly handle UTF8 filenames --- .../Testing/Cxx/TestSystemInformation.cxx | 5 +++-- .../Testing/Cxx/TestXMLFileOutputWindow.cxx | 5 +++-- Common/Core/vtkFileOutputWindow.cxx | 10 +++++++++ Common/Core/vtkWin32OutputWindow.cxx | 4 ++-- Common/Core/vtkXMLFileOutputWindow.cxx | 11 ++++++++++ Common/DataModel/vtkXMLDataElement.cxx | 3 ++- Common/System/vtkTimerLog.cxx | 3 ++- .../Testing/Cxx/GenerateBlueObeliskHeader.cxx | 2 +- Domains/Chemistry/vtkGaussianCubeReader2.cxx | 5 +++-- Domains/Chemistry/vtkVASPAnimationReader.cxx | 5 +++-- .../Chemistry/vtkVASPTessellationReader.cxx | 5 +++-- Domains/Chemistry/vtkXYZMolReader2.cxx | 5 +++-- .../Cxx/ImageBenchmarkDriver.cxx | 2 +- Filters/Hybrid/vtkFacetReader.cxx | 5 +++-- Filters/Parallel/vtkPipelineSize.cxx | 7 ++++--- .../vtkPStructuredGridConnectivity.cxx | 8 +++---- .../TestRealDataPDescriptiveStatisticsMPI.cxx | 8 +++---- .../Testing/Cxx/TestIOADIOS2VTX_VTU3D.cxx | 2 +- IO/ADIOS2/VTX/common/VTXHelper.cxx | 2 +- IO/AMR/vtkAMREnzoReader.cxx | 3 ++- IO/AMR/vtkAMREnzoReaderInternal.cxx | 5 +++-- IO/AMR/vtkAMReXGridReaderInternal.cxx | 3 ++- IO/AMR/vtkAMReXParticlesReader.cxx | 7 ++++--- IO/Asynchronous/vtkThreadedImageWriter.cxx | 5 +++-- IO/Core/vtkArrayDataReader.cxx | 3 ++- IO/Core/vtkArrayDataWriter.cxx | 5 +++-- IO/Core/vtkArrayReader.cxx | 3 ++- IO/Core/vtkArrayWriter.cxx | 5 +++-- IO/Core/vtkDelimitedTextWriter.cxx | 3 ++- IO/Core/vtkJavaScriptDataWriter.cxx | 5 +++++ IO/EnSight/vtkEnSight6BinaryReader.cxx | 4 +++- IO/EnSight/vtkEnSight6Reader.cxx | 17 ++++++++------- IO/EnSight/vtkEnSightGoldBinaryReader.cxx | 4 +++- IO/EnSight/vtkEnSightGoldReader.cxx | 17 ++++++++------- IO/EnSight/vtkEnSightMasterServerReader.cxx | 3 ++- IO/EnSight/vtkEnSightReader.cxx | 3 ++- IO/EnSight/vtkGenericEnSightReader.cxx | 5 +++-- IO/Export/vtkGLTFExporter.cxx | 7 ++++--- IO/Export/vtkJSONDataSetWriter.cxx | 5 +++-- IO/Export/vtkJSONSceneExporter.cxx | 3 ++- IO/Export/vtkOBJExporter.cxx | 9 ++++---- IO/Export/vtkOBJExporter.h | 2 +- IO/Export/vtkX3DExporterFIWriter.cxx | 3 ++- IO/Export/vtkX3DExporterXMLWriter.cxx | 3 ++- IO/GeoJSON/vtkGeoJSONReader.cxx | 2 +- IO/GeoJSON/vtkGeoJSONWriter.cxx | 2 +- IO/Geometry/vtkAVSucdReader.cxx | 9 +++++++- IO/Geometry/vtkFLUENTReader.cxx | 11 +++++----- IO/Geometry/vtkFacetWriter.cxx | 3 ++- IO/Geometry/vtkGAMBITReader.cxx | 5 +++++ IO/Geometry/vtkGLTFDocumentLoader.cxx | 5 +++-- .../vtkGLTFDocumentLoaderInternals.cxx | 9 ++++---- IO/Geometry/vtkGLTFUtils.cxx | 9 ++++---- IO/Geometry/vtkHoudiniPolyDataWriter.cxx | 3 ++- IO/Geometry/vtkMFIXReader.cxx | 21 ++++++++++--------- IO/Geometry/vtkOBJWriter.cxx | 13 ++++++------ IO/Geometry/vtkPTSReader.cxx | 3 ++- IO/Geometry/vtkParticleReader.cxx | 4 +++- IO/Geometry/vtkWindBladeReader.cxx | 9 ++++---- .../Cxx/TestPNGReaderReadFromMemory.cxx | 3 ++- IO/Image/vtkImageReader2.cxx | 4 +++- IO/Image/vtkImageWriter.cxx | 5 +++-- IO/Image/vtkJSONImageWriter.cxx | 3 ++- IO/Image/vtkMRCReader.cxx | 12 ++++++----- IO/Image/vtkMetaImageReader.cxx | 3 ++- IO/Image/vtkNrrdReader.cxx | 7 ++++--- IO/Image/vtkSEPReader.cxx | 3 ++- IO/Import/vtkOBJImporterInternals.cxx | 3 ++- IO/Infovis/vtkBiomTableReader.cxx | 3 ++- IO/Infovis/vtkChacoGraphReader.cxx | 3 ++- IO/Infovis/vtkDIMACSGraphReader.cxx | 10 ++++----- IO/Infovis/vtkDelimitedTextReader.cxx | 3 ++- IO/Infovis/vtkFixedWidthTextReader.cxx | 3 ++- IO/Infovis/vtkISIReader.cxx | 3 ++- IO/Infovis/vtkMultiNewickTreeReader.cxx | 3 ++- IO/Infovis/vtkNewickTreeReader.cxx | 3 ++- IO/Infovis/vtkRISReader.cxx | 3 ++- IO/Infovis/vtkTulipReader.cxx | 3 ++- IO/Infovis/vtkXGMLReader.cxx | 3 ++- IO/LAS/vtkLASReader.cxx | 2 +- IO/LSDyna/vtkLSDynaReader.cxx | 11 +++++----- IO/LSDyna/vtkLSDynaReader.h | 4 ++-- IO/Legacy/vtkDataReader.cxx | 7 ++++--- IO/Legacy/vtkDataWriter.cxx | 7 ++++--- IO/Legacy/vtkSimplePointsReader.cxx | 3 ++- IO/Legacy/vtkSimplePointsWriter.cxx | 3 ++- IO/MINC/vtkMNIObjectReader.cxx | 5 +++-- IO/MINC/vtkMNIObjectWriter.cxx | 7 ++++--- IO/MINC/vtkMNITagPointReader.cxx | 5 +++-- IO/MINC/vtkMNITagPointWriter.cxx | 3 ++- IO/MINC/vtkMNITransformReader.cxx | 5 +++-- IO/MINC/vtkMNITransformWriter.cxx | 3 ++- IO/PLY/Testing/Cxx/TestPLYWriterString.cxx | 5 +++-- IO/PLY/vtkPLY.cxx | 15 ++++++------- IO/Parallel/vtkPDataSetReader.cxx | 9 ++++++-- IO/Parallel/vtkPDataSetReader.h | 4 ++-- IO/Parallel/vtkPDataSetWriter.cxx | 3 ++- IO/Parallel/vtkPImageWriter.cxx | 7 ++++--- IO/Parallel/vtkPlot3DMetaReader.cxx | 3 ++- .../Cxx/TestParallelUnstructuredGridIO.cxx | 3 ++- .../Testing/Cxx/TestSQLiteTableReadWrite.cxx | 7 ++++--- IO/SQL/vtkSQLiteDatabase.cxx | 3 ++- IO/TecplotTable/vtkTecplotTableReader.cxx | 3 ++- .../Cxx/TestReadDuplicateDataArrayNames.cxx | 3 ++- .../Cxx/TestXMLMappedUnstructuredGridIO.cxx | 9 ++++---- IO/XML/vtkXMLFileReadTester.cxx | 3 ++- IO/XML/vtkXMLReader.cxx | 4 +++- IO/XML/vtkXMLWriter.cxx | 4 +++- IO/XMLParser/vtkXMLParser.cxx | 3 ++- IO/XMLParser/vtkXMLUtilities.cxx | 5 +++-- IO/Xdmf2/vtkXdmfReader.cxx | 2 +- Infovis/Core/vtkWordCloud.cxx | 5 +++-- .../Cxx/TestPickingManagerSeedWidget.cxx | 3 ++- Parallel/Core/vtkSocketCommunicator.cxx | 7 +++++++ Rendering/Core/vtkInteractorEventRecorder.cxx | 5 +++-- Rendering/Label/vtkDynamic2DLabelMapper.cxx | 2 +- Rendering/OpenGL2/vtkShaderProgram.cxx | 5 +++-- Rendering/OpenVR/vtkOpenVROverlay.cxx | 4 ++-- Rendering/Parallel/vtkCompositeZPass.cxx | 16 +++++++------- Rendering/ParallelLIC/vtkParallelTimer.cxx | 3 ++- .../RayTracing/vtkOSPRayMaterialLibrary.cxx | 2 +- .../TestGPURayCastClippingUserTransform.cxx | 3 ++- Utilities/Benchmarks/vtkRenderTimings.cxx | 2 +- Web/WebGLExporter/vtkPVWebGLExporter.cxx | 5 +++-- Web/WebGLExporter/vtkWebGLExporter.cxx | 2 +- 125 files changed, 398 insertions(+), 246 deletions(-) diff --git a/Common/Core/Testing/Cxx/TestSystemInformation.cxx b/Common/Core/Testing/Cxx/TestSystemInformation.cxx index 27425071456..7e7bd733ba5 100644 --- a/Common/Core/Testing/Cxx/TestSystemInformation.cxx +++ b/Common/Core/Testing/Cxx/TestSystemInformation.cxx @@ -19,6 +19,7 @@ #include "vtkDebugLeaks.h" #include <string> +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> void vtkSystemInformationPrintFile(const char* name, ostream& os) @@ -32,9 +33,9 @@ void vtkSystemInformationPrintFile(const char* name, ostream& os) } #ifdef _WIN32 - ifstream fin(name, ios::in | ios::binary); + vtksys::ifstream fin(name, ios::in | ios::binary); #else - ifstream fin(name, ios::in); + vtksys::ifstream fin(name, ios::in); #endif if (fin) diff --git a/Common/Core/Testing/Cxx/TestXMLFileOutputWindow.cxx b/Common/Core/Testing/Cxx/TestXMLFileOutputWindow.cxx index 633271d9b37..a747aaec6b2 100644 --- a/Common/Core/Testing/Cxx/TestXMLFileOutputWindow.cxx +++ b/Common/Core/Testing/Cxx/TestXMLFileOutputWindow.cxx @@ -15,6 +15,7 @@ #include "vtkXMLFileOutputWindow.h" #include "vtkSmartPointer.h" +#include "vtksys/FStream.hxx" #include <string> int TestXMLFileOutputWindow(int argc, char* argv[]) @@ -73,7 +74,7 @@ int TestXMLFileOutputWindow(int argc, char* argv[]) // Now, compare the default and specified files // Read the default XML file - std::ifstream dfin("vtkMessageLog.xml"); + vtksys::ifstream dfin("vtkMessageLog.xml"); std::string def((std::istreambuf_iterator<char>(dfin)), std::istreambuf_iterator<char>()); if (dfin.fail()) @@ -82,7 +83,7 @@ int TestXMLFileOutputWindow(int argc, char* argv[]) return EXIT_FAILURE; } - std::ifstream sfin(argv[1]); + vtksys::ifstream sfin(argv[1]); std::string specified((std::istreambuf_iterator<char>(sfin)), std::istreambuf_iterator<char>()); if (sfin.fail()) diff --git a/Common/Core/vtkFileOutputWindow.cxx b/Common/Core/vtkFileOutputWindow.cxx index 1ce5915c225..45b20271a89 100644 --- a/Common/Core/vtkFileOutputWindow.cxx +++ b/Common/Core/vtkFileOutputWindow.cxx @@ -14,6 +14,7 @@ =========================================================================*/ #include "vtkFileOutputWindow.h" #include "vtkObjectFactory.h" +#include "vtksys/FStream.hxx" vtkStandardNewMacro(vtkFileOutputWindow); @@ -43,11 +44,20 @@ void vtkFileOutputWindow::Initialize() } if (this->Append) { +#ifdef _WIN32 + this->OStream = + new ofstream(vtksys::Encoding::ToWindowsExtendedPath(this->FileName), ios::app); +#else this->OStream = new ofstream(this->FileName, ios::app); +#endif } else { +#ifdef _WIN32 + this->OStream = new ofstream(vtksys::Encoding::ToWindowsExtendedPath(this->FileName)); +#else this->OStream = new ofstream(this->FileName); +#endif } } } diff --git a/Common/Core/vtkWin32OutputWindow.cxx b/Common/Core/vtkWin32OutputWindow.cxx index 976ab17b2c4..d552c26aecb 100644 --- a/Common/Core/vtkWin32OutputWindow.cxx +++ b/Common/Core/vtkWin32OutputWindow.cxx @@ -347,14 +347,14 @@ bool vtkWin32OutputWindow::GetSendToStdErr() void vtkWin32OutputWindow::SendToStdErrOn() { VTK_LEGACY_REPLACED_BODY( - vtkWin32OutputWindow::SendToStdErrOn, "VTK 8.3", vtkWin32OutputWindow::SetDisplayMode) + vtkWin32OutputWindow::SendToStdErrOn, "VTK 8.3", vtkWin32OutputWindow::SetDisplayMode); this->SetDisplayMode(ALWAYS_STDERR); } void vtkWin32OutputWindow::SendToStdErrOff() { VTK_LEGACY_REPLACED_BODY( - vtkWin32OutputWindow::SendToStdErrOff, "VTK 8.3", vtkWin32OutputWindow::SetDisplayMode) + vtkWin32OutputWindow::SendToStdErrOff, "VTK 8.3", vtkWin32OutputWindow::SetDisplayMode); this->SetDisplayMode(DEFAULT); } #endif diff --git a/Common/Core/vtkXMLFileOutputWindow.cxx b/Common/Core/vtkXMLFileOutputWindow.cxx index 08f8895752d..187fbe689be 100644 --- a/Common/Core/vtkXMLFileOutputWindow.cxx +++ b/Common/Core/vtkXMLFileOutputWindow.cxx @@ -14,6 +14,7 @@ =========================================================================*/ #include "vtkXMLFileOutputWindow.h" #include "vtkObjectFactory.h" +#include "vtksys/Encoding.hxx" vtkStandardNewMacro(vtkXMLFileOutputWindow); @@ -27,13 +28,23 @@ void vtkXMLFileOutputWindow::Initialize() this->FileName = new char[strlen(fileName) + 1]; strcpy(this->FileName, fileName); } + if (this->Append) { +#ifdef _WIN32 + this->OStream = + new ofstream(vtksys::Encoding::ToWindowsExtendedPath(this->FileName), ios::app); +#else this->OStream = new ofstream(this->FileName, ios::app); +#endif } else { +#ifdef _WIN32 + this->OStream = new ofstream(vtksys::Encoding::ToWindowsExtendedPath(this->FileName)); +#else this->OStream = new ofstream(this->FileName); +#endif this->DisplayTag("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); } } diff --git a/Common/DataModel/vtkXMLDataElement.cxx b/Common/DataModel/vtkXMLDataElement.cxx index b55b947e396..52a50bbd853 100644 --- a/Common/DataModel/vtkXMLDataElement.cxx +++ b/Common/DataModel/vtkXMLDataElement.cxx @@ -21,6 +21,7 @@ using std::istringstream; using std::ostringstream; #include <string> +#include <vtksys/FStream.hxx>> #include <vtksys/SystemTools.hxx> using std::string; #include <locale> // C++ locale @@ -442,7 +443,7 @@ void vtkXMLDataElement::PrintWithEscapedData(ostream& os, const char* data) //---------------------------------------------------------------------------- void vtkXMLDataElement::PrintXML(const char* fname) { - ofstream of(fname); + vtksys::ofstream of(fname); of.imbue(std::locale::classic()); this->PrintXML(of, vtkIndent()); } diff --git a/Common/System/vtkTimerLog.cxx b/Common/System/vtkTimerLog.cxx index 033f2989910..0ecb24b2f08 100644 --- a/Common/System/vtkTimerLog.cxx +++ b/Common/System/vtkTimerLog.cxx @@ -25,6 +25,7 @@ #include "vtkTimerLog.h" #include "vtkMath.h" +#include "vtksys/FStream.hxx" #include <algorithm> #include <cassert> @@ -545,7 +546,7 @@ void vtkTimerLog::DumpLogWithIndentsAndPercentages(std::ostream* os) void vtkTimerLog::DumpLog(const char* filename) { #ifndef _WIN32_WCE - ofstream os_with_warning_C4701(filename); + vtksys::ofstream os_with_warning_C4701(filename); int i; if (vtkTimerLog::WrapFlag) diff --git a/Domains/Chemistry/Testing/Cxx/GenerateBlueObeliskHeader.cxx b/Domains/Chemistry/Testing/Cxx/GenerateBlueObeliskHeader.cxx index b2914762766..b057ac3b2da 100644 --- a/Domains/Chemistry/Testing/Cxx/GenerateBlueObeliskHeader.cxx +++ b/Domains/Chemistry/Testing/Cxx/GenerateBlueObeliskHeader.cxx @@ -19,7 +19,7 @@ int GenerateBlueObeliskHeader(int, char*[]) { - std::ifstream xml(VTK_BODR_DATA_PATH_BUILD "/elements.xml"); + vtksys::ifstream xml(VTK_BODR_DATA_PATH_BUILD "/elements.xml"); if (!xml) { std::cerr << "Error opening file " VTK_BODR_DATA_PATH_BUILD "/elements.xml.\n"; diff --git a/Domains/Chemistry/vtkGaussianCubeReader2.cxx b/Domains/Chemistry/vtkGaussianCubeReader2.cxx index c666754dd96..dbd3f523bc2 100644 --- a/Domains/Chemistry/vtkGaussianCubeReader2.cxx +++ b/Domains/Chemistry/vtkGaussianCubeReader2.cxx @@ -29,6 +29,7 @@ #include "vtkSimpleBondPerceiver.h" #include "vtkStreamingDemandDrivenPipeline.h" #include "vtkTransform.h" +#include "vtksys/FStream.hxx" #include <fstream> #include <iostream> @@ -94,7 +95,7 @@ int vtkGaussianCubeReader2::RequestInformation(vtkInformation* vtkNotUsed(reques return 0; } - ifstream file_in(this->FileName); + vtksys::ifstream file_in(this->FileName); if (!file_in.is_open()) { @@ -169,7 +170,7 @@ int vtkGaussianCubeReader2::RequestData( return 0; } - ifstream file_in(this->FileName); + vtksys::ifstream file_in(this->FileName); if (!file_in.is_open()) { diff --git a/Domains/Chemistry/vtkVASPAnimationReader.cxx b/Domains/Chemistry/vtkVASPAnimationReader.cxx index 4bcffd33a52..73c45f7fa8e 100644 --- a/Domains/Chemistry/vtkVASPAnimationReader.cxx +++ b/Domains/Chemistry/vtkVASPAnimationReader.cxx @@ -25,6 +25,7 @@ #include "vtkStreamingDemandDrivenPipeline.h" #include "vtkVectorOperators.h" +#include <vtksys/FStream.hxx> #include <vtksys/RegularExpression.hxx> #include <algorithm> @@ -102,7 +103,7 @@ int vtkVASPAnimationReader::RequestData( vtkMolecule* output = vtkMolecule::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); assert(output); - std::ifstream in(this->FileName); + vtksys::ifstream in(this->FileName); if (!in) { vtkErrorMacro("Could not open file for reading: " << (this->FileName ? this->FileName : "")); @@ -138,7 +139,7 @@ int vtkVASPAnimationReader::RequestData( int vtkVASPAnimationReader::RequestInformation( vtkInformation*, vtkInformationVector**, vtkInformationVector* outInfos) { - std::ifstream in(this->FileName); + vtksys::ifstream in(this->FileName); if (!in) { vtkErrorMacro("Could not open file for reading: " << (this->FileName ? this->FileName : "")); diff --git a/Domains/Chemistry/vtkVASPTessellationReader.cxx b/Domains/Chemistry/vtkVASPTessellationReader.cxx index 2b07d785627..068c78bc89b 100644 --- a/Domains/Chemistry/vtkVASPTessellationReader.cxx +++ b/Domains/Chemistry/vtkVASPTessellationReader.cxx @@ -34,6 +34,7 @@ #include "vtkVector.h" #include "vtkVectorOperators.h" +#include "vtksys/FStream.hxx" #include <vtksys/RegularExpression.hxx> #include <algorithm> @@ -175,7 +176,7 @@ int vtkVASPTessellationReader::RequestData( vtkUnstructuredGrid::SafeDownCast(outInfo1->Get(vtkDataObject::DATA_OBJECT())); assert(voronoi); - std::ifstream in(this->FileName); + vtksys::ifstream in(this->FileName); if (!in) { vtkErrorMacro("Could not open file for reading: " << (this->FileName ? this->FileName : "")); @@ -213,7 +214,7 @@ int vtkVASPTessellationReader::RequestData( int vtkVASPTessellationReader::RequestInformation( vtkInformation*, vtkInformationVector**, vtkInformationVector* outInfos) { - std::ifstream in(this->FileName); + vtksys::ifstream in(this->FileName); if (!in) { vtkErrorMacro("Could not open file for reading: " << (this->FileName ? this->FileName : "")); diff --git a/Domains/Chemistry/vtkXYZMolReader2.cxx b/Domains/Chemistry/vtkXYZMolReader2.cxx index 5e840708d5c..7adf51d8d18 100644 --- a/Domains/Chemistry/vtkXYZMolReader2.cxx +++ b/Domains/Chemistry/vtkXYZMolReader2.cxx @@ -23,6 +23,7 @@ #include "vtkPeriodicTable.h" #include "vtkStreamingDemandDrivenPipeline.h" +#include "vtksys/FStream.hxx" #include <cmath> #include <cstring> @@ -68,7 +69,7 @@ int vtkXYZMolReader2::RequestInformation(vtkInformation* vtkNotUsed(request), return 0; } - ifstream file_in(this->FileName); + vtksys::ifstream file_in(this->FileName); if (!file_in.is_open()) { @@ -157,7 +158,7 @@ int vtkXYZMolReader2::RequestData( return 0; } - ifstream file_in(this->FileName); + vtksys::ifstream file_in(this->FileName); if (!file_in.is_open()) { diff --git a/Examples/ImageProcessing/Cxx/ImageBenchmarkDriver.cxx b/Examples/ImageProcessing/Cxx/ImageBenchmarkDriver.cxx index 8fffc272e9e..9931a3a2c65 100644 --- a/Examples/ImageProcessing/Cxx/ImageBenchmarkDriver.cxx +++ b/Examples/ImageProcessing/Cxx/ImageBenchmarkDriver.cxx @@ -237,7 +237,7 @@ int main(int argc, char* argv[]) commandLine.push_back(nullptr); filename += ".csv"; - std::ofstream outfile(filename.c_str()); + vtksys::ofstream outfile(filename.c_str()); // create and run the subprocess vtksysProcess* process = vtksysProcess_New(); diff --git a/Filters/Hybrid/vtkFacetReader.cxx b/Filters/Hybrid/vtkFacetReader.cxx index 971eb07789a..e784a02a1d9 100644 --- a/Filters/Hybrid/vtkFacetReader.cxx +++ b/Filters/Hybrid/vtkFacetReader.cxx @@ -29,6 +29,7 @@ #include "vtkSmartPointer.h" #include "vtkUnsignedIntArray.h" +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> #include <sstream> @@ -101,7 +102,7 @@ int vtkFacetReader::CanReadFile(const char* filename) return 0; } - ifstream ifs(filename, ios::in); + vtksys::ifstream ifs(filename, ios::in); if (!ifs) { // Specified filename not found @@ -144,7 +145,7 @@ int vtkFacetReader::RequestData(vtkInformation* vtkNotUsed(request), return 1; } - ifstream ifs(this->FileName, ios::in); + vtksys::ifstream ifs(this->FileName, ios::in); if (!ifs) { this->SetErrorCode(vtkErrorCode::FileNotFoundError); diff --git a/Filters/Parallel/vtkPipelineSize.cxx b/Filters/Parallel/vtkPipelineSize.cxx index 53a5b2e0573..d4d30acb0ac 100644 --- a/Filters/Parallel/vtkPipelineSize.cxx +++ b/Filters/Parallel/vtkPipelineSize.cxx @@ -28,6 +28,7 @@ #include "vtkPolyData.h" #include "vtkPolyDataMapper.h" #include "vtkStreamingDemandDrivenPipeline.h" +#include "vtksys/FStream.hxx" vtkStandardNewMacro(vtkPipelineSize); @@ -62,12 +63,12 @@ void vtkPipelineSize::ComputeSourcePipelineSize( // handle vtkDataReader subclasses if (src->IsA("vtkDataReader")) { - ifstream* ifs; + vtksys::ifstream* ifs; vtkDataReader* rdr = vtkDataReader::SafeDownCast(src); #ifdef _WIN32 - ifs = new ifstream(rdr->GetFileName(), ios::in | ios::binary); + ifs = new vtksys::ifstream(rdr->GetFileName(), ios::in | ios::binary); #else - ifs = new ifstream(rdr->GetFileName(), ios::in); + ifs = new vtksys::ifstream(rdr->GetFileName(), ios::in); #endif if (!ifs->fail()) { diff --git a/Filters/ParallelGeometry/vtkPStructuredGridConnectivity.cxx b/Filters/ParallelGeometry/vtkPStructuredGridConnectivity.cxx index aea84335fbd..258f9c5c303 100644 --- a/Filters/ParallelGeometry/vtkPStructuredGridConnectivity.cxx +++ b/Filters/ParallelGeometry/vtkPStructuredGridConnectivity.cxx @@ -144,7 +144,7 @@ void vtkPStructuredGridConnectivity::CreateGhostLayers(const int N) // BEGIN DEBUG // std::ostringstream oss; // oss << "Process" << this->Rank << "-neis.log"; - // std::ofstream ofs; + // vtksys::ofstream ofs; // ofs.open( oss.str().c_str() ); // assert("ERROR: cannot write log file" && ofs.is_open() ); // this->Print( ofs ); @@ -1188,7 +1188,7 @@ void vtkPStructuredGridConnectivity::SerializeGhostData(const int sendGridID, co // BEGIN DEBUG // std::ostringstream oss; // oss << "SendLog_" << this->Rank << ".txt"; - // std::ofstream ofs; + // vtksys::ofstream ofs; // ofs.open( oss.str().c_str() ); // ofs << "SEND MESSAGE SIZE: " << size << "\n"; // ofs << sendGridID << " " << rcvGrid << std::endl; @@ -1232,7 +1232,7 @@ void vtkPStructuredGridConnectivity::DeserializeGhostData(const int gridID, cons // BEGIN DEBUG // std::ostringstream oss; // oss << "RcvLog_" << this->Rank << ".txt"; - // std::ofstream ofs; + // vtksys::ofstream ofs; // ofs.open( oss.str().c_str() ); // ofs << "RCV MESSAGE SIZE: " << size << "\n"; // ofs << remoteGrid << " " << rcvGrid << std::endl; @@ -1250,7 +1250,7 @@ void vtkPStructuredGridConnectivity::DeserializeGhostData(const int gridID, cons // std::ostringstream oss; // oss << "Extents-" << this->Rank << "-" << neiGridIdx << ".txt"; - // std::ofstream ofs; + // vtksys::ofstream ofs; // ofs.open( oss.str().c_str() ); // assert( ofs.is_open() ); // diff --git a/Filters/ParallelStatistics/Testing/Cxx/TestRealDataPDescriptiveStatisticsMPI.cxx b/Filters/ParallelStatistics/Testing/Cxx/TestRealDataPDescriptiveStatisticsMPI.cxx index e0278cd1fb8..4f902ce57ca 100644 --- a/Filters/ParallelStatistics/Testing/Cxx/TestRealDataPDescriptiveStatisticsMPI.cxx +++ b/Filters/ParallelStatistics/Testing/Cxx/TestRealDataPDescriptiveStatisticsMPI.cxx @@ -72,7 +72,7 @@ int CalculateProcessorRank(int* procDim, int* procId) // Read a block of data bounded by [low, high] from file into buffer. // The entire data has dimensions dim -int ReadFloatDataBlockFromFile(ifstream& ifs, int* dim, int* low, int* high, float* buffer) +int ReadFloatDataBlockFromFile(istream& ifs, int* dim, int* low, int* high, float* buffer) { vtkIdType dimXY = dim[0] * dim[1]; vtkIdType dimX = dim[0]; @@ -145,8 +145,8 @@ int ReadFloatDataBlockFromFile(ifstream& ifs, int* dim, int* low, int* high, flo // Given the data dimensions dataDim, the process dimensions procDim, my // process id myProcId, set the block bounding box myBlockBounds for my data. // Also open the data file as filestream ifs. -int SetDataParameters(int* dataDim, int* procDim, int* myProcId, const char* fileName, - ifstream& ifs, int myBlockBounds[2][3]) +int SetDataParameters(int* dataDim, int* procDim, int* myProcId, const char* fileName, istream& ifs, + int myBlockBounds[2][3]) { vtkIdType myDim[3]; myDim[0] = static_cast<int>(ceil(dataDim[0] / (1. * procDim[0]))); @@ -198,7 +198,7 @@ void RealDataDescriptiveStatistics(vtkMultiProcessController* controller, void* timer->StartTimer(); // ************************** Read input data file **************************** - ifstream ifs; + vtksys::ifstream ifs; int myBlockBounds[2][3]; if (SetDataParameters(args->dataDim, args->procDim, myProcId, args->fileName, ifs, myBlockBounds)) { diff --git a/IO/ADIOS2/Testing/Cxx/TestIOADIOS2VTX_VTU3D.cxx b/IO/ADIOS2/Testing/Cxx/TestIOADIOS2VTX_VTU3D.cxx index e772504b780..9cd483c0487 100644 --- a/IO/ADIOS2/Testing/Cxx/TestIOADIOS2VTX_VTU3D.cxx +++ b/IO/ADIOS2/Testing/Cxx/TestIOADIOS2VTX_VTU3D.cxx @@ -301,7 +301,7 @@ void WriteBPFile3DVars(const std::string& fileName, const size_t steps, const in ? fileName + "/vtk.xml" : fileName + ".dir/vtk.xml"; - std::ofstream fxml(vtkFileName, ofstream::out); + vtksys::ofstream fxml(vtkFileName, vtksys::ofstream::out); fxml << unstructureGridSchema << "\n"; fxml.close(); } diff --git a/IO/ADIOS2/VTX/common/VTXHelper.cxx b/IO/ADIOS2/VTX/common/VTXHelper.cxx index 5d335fc71fa..be22d64a8d3 100644 --- a/IO/ADIOS2/VTX/common/VTXHelper.cxx +++ b/IO/ADIOS2/VTX/common/VTXHelper.cxx @@ -251,7 +251,7 @@ types::DataSet XMLInitDataSet( std::string FileToString(const std::string& fileName) { - std::ifstream file(fileName); + vtksys::ifstream file(fileName); std::stringstream schemaSS; schemaSS << file.rdbuf(); return schemaSS.str(); diff --git a/IO/AMR/vtkAMREnzoReader.cxx b/IO/AMR/vtkAMREnzoReader.cxx index bc664325861..84048df0340 100644 --- a/IO/AMR/vtkAMREnzoReader.cxx +++ b/IO/AMR/vtkAMREnzoReader.cxx @@ -22,6 +22,7 @@ #include "vtkOverlappingAMR.h" #include "vtkPolyData.h" #include "vtkUniformGrid.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include "vtkCellData.h" @@ -182,7 +183,7 @@ void vtkAMREnzoReader::ParseConversionFactors() baseDir + "/" + vtksys::SystemTools::GetFilenameWithoutExtension(std::string(this->FileName)); // STEP 1: Open Parameters file - std::ifstream ifs; + vtksys::ifstream ifs; ifs.open(paramsFile.c_str()); if (!ifs.is_open()) { diff --git a/IO/AMR/vtkAMREnzoReaderInternal.cxx b/IO/AMR/vtkAMREnzoReaderInternal.cxx index cd31284c3f8..dadaf0ca81b 100644 --- a/IO/AMR/vtkAMREnzoReaderInternal.cxx +++ b/IO/AMR/vtkAMREnzoReaderInternal.cxx @@ -31,6 +31,7 @@ #include "vtkUnsignedCharArray.h" #include "vtkUnsignedIntArray.h" #include "vtkUnsignedShortArray.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" // ---------------------------------------------------------------------------- @@ -586,7 +587,7 @@ int vtkEnzoReaderInternal::LoadAttribute(const char* attribute, int blockIdx) // block file name, and particle file name of each block void vtkEnzoReaderInternal::ReadBlockStructures() { - ifstream stream(this->HierarchyFileName.c_str()); + vtksys::ifstream stream(this->HierarchyFileName.c_str()); if (!stream) { vtkGenericWarningMacro( @@ -815,7 +816,7 @@ void vtkEnzoReaderInternal::ReadBlockStructures() // obtain the general information of the dataset (number of dimensions) void vtkEnzoReaderInternal::ReadGeneralParameters() { - ifstream stream(this->MajorFileName.c_str()); + vtksys::ifstream stream(this->MajorFileName.c_str()); if (!stream) { vtkGenericWarningMacro("Invalid parameter file " << this->MajorFileName.c_str() << endl); diff --git a/IO/AMR/vtkAMReXGridReaderInternal.cxx b/IO/AMR/vtkAMReXGridReaderInternal.cxx index 576fe98cd27..62cb40a9110 100644 --- a/IO/AMR/vtkAMReXGridReaderInternal.cxx +++ b/IO/AMR/vtkAMReXGridReaderInternal.cxx @@ -24,13 +24,14 @@ #include <sstream> #include <vector> +#include <vtksys/FStream.hxx> namespace { std::string ReadFile(const std::string& filename) { std::string contents; - std::ifstream stream(filename, std::ios::binary); + vtksys::ifstream stream(filename.c_str(), std::ios::binary); if (stream) { stream.seekg(0, std::ios::end); diff --git a/IO/AMR/vtkAMReXParticlesReader.cxx b/IO/AMR/vtkAMReXParticlesReader.cxx index 56e02a12f94..8a80e64fd9e 100644 --- a/IO/AMR/vtkAMReXParticlesReader.cxx +++ b/IO/AMR/vtkAMReXParticlesReader.cxx @@ -29,6 +29,7 @@ #include "vtkPolyData.h" #include "vtkSOADataArrayTemplate.h" #include "vtkStreamingDemandDrivenPipeline.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include <algorithm> @@ -49,7 +50,7 @@ std::string ReadAndBroadCastFile(const std::string& filename, vtkMultiProcessCon std::string contents; if (controller == nullptr || controller->GetLocalProcessId() == 0) { - std::ifstream stream(filename, std::ios::binary); + vtksys::ifstream stream(filename.c_str(), std::ios::binary); if (stream) { stream.seekg(0, std::ios::end); @@ -531,7 +532,7 @@ public: const std::string& fname = this->GetDATAFileName(self->PlotFileName, self->ParticleType, level, gridInfo.which); - std::ifstream ifp(fname, std::ios::binary); + vtksys::ifstream ifp(fname.c_str(), std::ios::binary); if (!ifp.good()) { return false; @@ -648,7 +649,7 @@ int vtkAMReXParticlesReader::CanReadFile(const char* fname, const char* particle const std::string header(particles + "/Header"); if (vtksystools::FileExists(header, /*isFile*/ true)) { - std::ifstream ifp(header.c_str(), std::ios::binary); + vtksys::ifstream ifp(header.c_str(), std::ios::binary); if (ifp) { std::string header_line; diff --git a/IO/Asynchronous/vtkThreadedImageWriter.cxx b/IO/Asynchronous/vtkThreadedImageWriter.cxx index 909c22b64a5..a6077d7f280 100644 --- a/IO/Asynchronous/vtkThreadedImageWriter.cxx +++ b/IO/Asynchronous/vtkThreadedImageWriter.cxx @@ -30,6 +30,7 @@ #include "vtkUnsignedCharArray.h" #include "vtkXMLImageDataWriter.h" #include "vtkZLibDataCompressor.h" +#include "vtksys/FStream.hxx" #include <cassert> #include <cmath> @@ -56,7 +57,7 @@ static void EncodeAndWrite(const vtkSmartPointer<vtkImageData>& image, const std size_t bufSize = image->GetNumberOfPoints() * sizeof(float); unsigned char* cBuffer = new unsigned char[bufSize]; size_t compressSize = zLib->Compress((unsigned char*)zBuf, bufSize, cBuffer, bufSize); - ofstream fileHandler(fileName.c_str(), ios::out | ios::binary); + vtksys::ofstream fileHandler(fileName.c_str(), ios::out | ios::binary); fileHandler.write((const char*)cBuffer, compressSize); delete[] cBuffer; } @@ -115,7 +116,7 @@ static void EncodeAndWrite(const vtkSmartPointer<vtkImageData>& image, const std int scalarSize = scalars->GetDataTypeSize(); const char* scalarPtr = static_cast<const char*>(scalars->GetVoidPointer(0)); size_t numberOfScalars = image->GetNumberOfPoints(); - ofstream fileHandler(fileName.c_str(), ios::out | ios::binary); + vtksys::ofstream fileHandler(fileName.c_str(), ios::out | ios::binary); fileHandler.write(scalarPtr, numberOfScalars * scalarSize); } } diff --git a/IO/Core/vtkArrayDataReader.cxx b/IO/Core/vtkArrayDataReader.cxx index 7a3be7ede2c..371e857fb2c 100644 --- a/IO/Core/vtkArrayDataReader.cxx +++ b/IO/Core/vtkArrayDataReader.cxx @@ -23,6 +23,7 @@ #include "vtkArrayReader.h" #include "vtkObjectFactory.h" #include "vtkSmartPointer.h" +#include "vtksys/FStream.hxx" #include <sstream> #include <stdexcept> @@ -75,7 +76,7 @@ int vtkArrayDataReader::RequestData( if (!this->FileName) throw std::runtime_error("FileName not set."); - ifstream file(this->FileName, std::ios::binary); + vtksys::ifstream file(this->FileName, std::ios::binary); array_data = this->Read(file); } diff --git a/IO/Core/vtkArrayDataWriter.cxx b/IO/Core/vtkArrayDataWriter.cxx index 11bbbb1122b..31211458f37 100644 --- a/IO/Core/vtkArrayDataWriter.cxx +++ b/IO/Core/vtkArrayDataWriter.cxx @@ -20,6 +20,7 @@ #include "vtkInformation.h" #include "vtkObjectFactory.h" #include "vtkSmartPointer.h" +#include "vtksys/FStream.hxx" #include <sstream> #include <stdexcept> @@ -72,13 +73,13 @@ int vtkArrayDataWriter::Write() bool vtkArrayDataWriter::Write(const vtkStdString& file_name, bool WriteBinary) { - ofstream file(file_name.c_str(), std::ios::binary); + vtksys::ofstream file(file_name.c_str(), std::ios::binary); return this->Write(file, WriteBinary); } bool vtkArrayDataWriter::Write(vtkArrayData* array, const vtkStdString& file_name, bool WriteBinary) { - ofstream file(file_name.c_str(), std::ios::binary); + vtksys::ofstream file(file_name.c_str(), std::ios::binary); return vtkArrayDataWriter::Write(array, file, WriteBinary); } diff --git a/IO/Core/vtkArrayReader.cxx b/IO/Core/vtkArrayReader.cxx index 4c69f301b4b..673efeed71f 100644 --- a/IO/Core/vtkArrayReader.cxx +++ b/IO/Core/vtkArrayReader.cxx @@ -26,6 +26,7 @@ #include "vtkSmartPointer.h" #include "vtkSparseArray.h" #include "vtkUnicodeString.h" +#include "vtksys/FStream.hxx" #include <sstream> #include <stdexcept> @@ -529,7 +530,7 @@ int vtkArrayReader::RequestData( if (!this->FileName) throw std::runtime_error("FileName not set."); - ifstream file(this->FileName, std::ios::binary); + vtksys::ifstream file(this->FileName, std::ios::binary); array = this->Read(file); } diff --git a/IO/Core/vtkArrayWriter.cxx b/IO/Core/vtkArrayWriter.cxx index 6afe93e2a56..6aaba118cf6 100644 --- a/IO/Core/vtkArrayWriter.cxx +++ b/IO/Core/vtkArrayWriter.cxx @@ -23,6 +23,7 @@ #include "vtkSmartPointer.h" #include "vtkSparseArray.h" #include "vtkUnicodeString.h" +#include "vtksys/FStream.hxx" #include <cmath> #include <limits> @@ -371,13 +372,13 @@ int vtkArrayWriter::Write() bool vtkArrayWriter::Write(const vtkStdString& file_name, bool WriteBinary) { - ofstream file(file_name.c_str(), std::ios::binary); + vtksys::ofstream file(file_name.c_str(), std::ios::binary); return this->Write(file, WriteBinary); } bool vtkArrayWriter::Write(vtkArray* array, const vtkStdString& file_name, bool WriteBinary) { - ofstream file(file_name.c_str(), std::ios::binary); + vtksys::ofstream file(file_name.c_str(), std::ios::binary); return vtkArrayWriter::Write(array, file, WriteBinary); } diff --git a/IO/Core/vtkDelimitedTextWriter.cxx b/IO/Core/vtkDelimitedTextWriter.cxx index 464753fdb0c..79a302c1ccc 100644 --- a/IO/Core/vtkDelimitedTextWriter.cxx +++ b/IO/Core/vtkDelimitedTextWriter.cxx @@ -29,6 +29,7 @@ #include "vtkObjectFactory.h" #include "vtkSmartPointer.h" #include "vtkTable.h" +#include "vtksys/FStream.hxx" #include <sstream> #include <vector> @@ -83,7 +84,7 @@ bool vtkDelimitedTextWriter::OpenStream() vtkDebugMacro(<< "Opening file for writing..."); - ofstream* fptr = new ofstream(this->FileName, ios::out); + vtksys::ofstream* fptr = new vtksys::ofstream(this->FileName, ios::out); if (fptr->fail()) { diff --git a/IO/Core/vtkJavaScriptDataWriter.cxx b/IO/Core/vtkJavaScriptDataWriter.cxx index 051d5baf4f3..f60f2072bee 100644 --- a/IO/Core/vtkJavaScriptDataWriter.cxx +++ b/IO/Core/vtkJavaScriptDataWriter.cxx @@ -30,6 +30,7 @@ #include "vtkSmartPointer.h" #include "vtkStringArray.h" #include "vtkTable.h" +#include "vtksys/Encoding.hxx" #include <sstream> #include <vector> @@ -83,7 +84,11 @@ ofstream* vtkJavaScriptDataWriter::OpenFile() vtkDebugMacro(<< "Opening file for writing..."); +#ifdef _WIN32 + ofstream* fptr = new ofstream(vtksys::Encoding::ToWindowsExtendedPath(this->FileName), ios::out); +#else ofstream* fptr = new ofstream(this->FileName, ios::out); +#endif if (fptr->fail()) { diff --git a/IO/EnSight/vtkEnSight6BinaryReader.cxx b/IO/EnSight/vtkEnSight6BinaryReader.cxx index 2bc42a03c61..ad3cdd10c9f 100644 --- a/IO/EnSight/vtkEnSight6BinaryReader.cxx +++ b/IO/EnSight/vtkEnSight6BinaryReader.cxx @@ -28,6 +28,7 @@ #include "vtkStructuredGrid.h" #include "vtkStructuredPoints.h" #include "vtkUnstructuredGrid.h" +#include "vtksys/Encoding.hxx" #include <cctype> #include <string> @@ -108,7 +109,8 @@ int vtkEnSight6BinaryReader::OpenFile(const char* filename) this->FileSize = static_cast<vtkTypeUInt64>(fs.st_size); #ifdef _WIN32 - this->BinaryIFile = new ifstream(filename, ios::in | ios::binary); + this->BinaryIFile = + new ifstream(vtksys::Encoding::ToWindowsExtendedPath(filename), ios::in | ios::binary); #else this->BinaryIFile = new ifstream(filename, ios::in); #endif diff --git a/IO/EnSight/vtkEnSight6Reader.cxx b/IO/EnSight/vtkEnSight6Reader.cxx index d99b3ae0c8b..a6efa69f10e 100644 --- a/IO/EnSight/vtkEnSight6Reader.cxx +++ b/IO/EnSight/vtkEnSight6Reader.cxx @@ -27,6 +27,7 @@ #include "vtkStructuredGrid.h" #include "vtkStructuredPoints.h" #include "vtkUnstructuredGrid.h" +#include "vtksys/FStream.hxx" #include <cassert> #include <cctype> @@ -195,7 +196,7 @@ int vtkEnSight6Reader::ReadGeometryFile( sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -377,7 +378,7 @@ int vtkEnSight6Reader::ReadMeasuredGeometryFile( sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -495,7 +496,7 @@ int vtkEnSight6Reader::ReadScalarsPerNode(const char* fileName, const char* desc sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -725,7 +726,7 @@ int vtkEnSight6Reader::ReadVectorsPerNode(const char* fileName, const char* desc sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -921,7 +922,7 @@ int vtkEnSight6Reader::ReadTensorsPerNode(const char* fileName, const char* desc sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -1070,7 +1071,7 @@ int vtkEnSight6Reader::ReadScalarsPerElement(const char* fileName, const char* d sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -1243,7 +1244,7 @@ int vtkEnSight6Reader::ReadVectorsPerElement(const char* fileName, const char* d sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -1406,7 +1407,7 @@ int vtkEnSight6Reader::ReadTensorsPerElement(const char* fileName, const char* d sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); diff --git a/IO/EnSight/vtkEnSightGoldBinaryReader.cxx b/IO/EnSight/vtkEnSightGoldBinaryReader.cxx index 62313ecc8d7..6e805c9c2e3 100644 --- a/IO/EnSight/vtkEnSightGoldBinaryReader.cxx +++ b/IO/EnSight/vtkEnSightGoldBinaryReader.cxx @@ -27,6 +27,7 @@ #include "vtkRectilinearGrid.h" #include "vtkStructuredGrid.h" #include "vtkUnstructuredGrid.h" +#include "vtksys/Encoding.hxx" #include <cctype> #include <map> @@ -116,7 +117,8 @@ int vtkEnSightGoldBinaryReader::OpenFile(const char* filename) this->FileSize = static_cast<vtkTypeUInt64>(fs.st_size); #ifdef _WIN32 - this->GoldIFile = new ifstream(filename, ios::in | ios::binary); + this->GoldIFile = + new ifstream(vtksys::Encoding::ToWindowsExtendedPath(filename), ios::in | ios::binary); #else this->GoldIFile = new ifstream(filename, ios::in); #endif diff --git a/IO/EnSight/vtkEnSightGoldReader.cxx b/IO/EnSight/vtkEnSightGoldReader.cxx index 37298f291db..de10b66ced7 100644 --- a/IO/EnSight/vtkEnSightGoldReader.cxx +++ b/IO/EnSight/vtkEnSightGoldReader.cxx @@ -26,6 +26,7 @@ #include "vtkRectilinearGrid.h" #include "vtkStructuredGrid.h" #include "vtkUnstructuredGrid.h" +#include "vtksys/FStream.hxx" #include <cctype> #include <map> @@ -109,7 +110,7 @@ int vtkEnSightGoldReader::ReadGeometryFile( sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -308,7 +309,7 @@ int vtkEnSightGoldReader::ReadMeasuredGeometryFile( sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -449,7 +450,7 @@ int vtkEnSightGoldReader::ReadScalarsPerNode(const char* fileName, const char* d sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -657,7 +658,7 @@ int vtkEnSightGoldReader::ReadVectorsPerNode(const char* fileName, const char* d sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -823,7 +824,7 @@ int vtkEnSightGoldReader::ReadTensorsPerNode(const char* fileName, const char* d sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -941,7 +942,7 @@ int vtkEnSightGoldReader::ReadScalarsPerElement(const char* fileName, const char sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -1140,7 +1141,7 @@ int vtkEnSightGoldReader::ReadVectorsPerElement(const char* fileName, const char sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); @@ -1303,7 +1304,7 @@ int vtkEnSightGoldReader::ReadTensorsPerElement(const char* fileName, const char sfilename = fileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); diff --git a/IO/EnSight/vtkEnSightMasterServerReader.cxx b/IO/EnSight/vtkEnSightMasterServerReader.cxx index 3385a83354f..2dd52542c91 100644 --- a/IO/EnSight/vtkEnSightMasterServerReader.cxx +++ b/IO/EnSight/vtkEnSightMasterServerReader.cxx @@ -17,6 +17,7 @@ #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkObjectFactory.h" +#include "vtksys/FStream.hxx" #include <string> @@ -114,7 +115,7 @@ int vtkEnSightMasterServerReader::DetermineFileName(int piece) sfilename = this->CaseFileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); diff --git a/IO/EnSight/vtkEnSightReader.cxx b/IO/EnSight/vtkEnSightReader.cxx index 291d9729a27..67590488f8e 100644 --- a/IO/EnSight/vtkEnSightReader.cxx +++ b/IO/EnSight/vtkEnSightReader.cxx @@ -28,6 +28,7 @@ #include "vtkStructuredGrid.h" #include "vtkStructuredPoints.h" #include "vtkUnstructuredGrid.h" +#include "vtksys/FStream.hxx" #include <algorithm> #include <string> @@ -1273,7 +1274,7 @@ int vtkEnSightReader::ReadCaseFile() sfilename = this->CaseFileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { vtkErrorMacro("Unable to open file: " << sfilename.c_str()); diff --git a/IO/EnSight/vtkGenericEnSightReader.cxx b/IO/EnSight/vtkGenericEnSightReader.cxx index 8be8ccd90c5..81ece2eb75e 100644 --- a/IO/EnSight/vtkGenericEnSightReader.cxx +++ b/IO/EnSight/vtkGenericEnSightReader.cxx @@ -27,6 +27,7 @@ #include "vtkInformationVector.h" #include "vtkMultiBlockDataSet.h" #include "vtkObjectFactory.h" +#include "vtksys/FStream.hxx" #include <vtksys/SystemTools.hxx> #include <cassert> @@ -322,7 +323,7 @@ int vtkGenericEnSightReader::DetermineEnSightVersion(int quiet) sfilename = this->CaseFileName; } - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); if (this->IS->fail()) { if (!quiet) @@ -1107,7 +1108,7 @@ int vtkGenericEnSightReader::ReplaceWildcards(char* fileName, int timeSet, int f } // We have got a valid CASE file name - this->IS = new ifstream(sfilename.c_str(), ios::in); + this->IS = new vtksys::ifstream(sfilename.c_str(), ios::in); // Below is a revamped version of the code in support of inline & non-inline // file name numbers, in a CASE file, of which the first one is obtained to diff --git a/IO/Export/vtkGLTFExporter.cxx b/IO/Export/vtkGLTFExporter.cxx index 318ad01590c..0c357a9045e 100644 --- a/IO/Export/vtkGLTFExporter.cxx +++ b/IO/Export/vtkGLTFExporter.cxx @@ -44,6 +44,7 @@ #include "vtkUnsignedCharArray.h" #include "vtkUnsignedIntArray.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" vtkStandardNewMacro(vtkGLTFExporter); @@ -87,7 +88,7 @@ vtkPolyData* findPolyData(vtkDataObject* input) return nullptr; } -void WriteValues(vtkDataArray* ca, ofstream& myFile) +void WriteValues(vtkDataArray* ca, ostream& myFile) { myFile.write(reinterpret_cast<char*>(ca->GetVoidPointer(0)), ca->GetNumberOfTuples() * ca->GetNumberOfComponents() * ca->GetElementComponentSize()); @@ -139,7 +140,7 @@ void WriteBufferAndView(vtkDataArray* inda, const char* fileName, bool inlineDat fullPath += result; // now write the data - ofstream myFile(fullPath, ios::out | ios::binary); + vtksys::ofstream myFile(fullPath.c_str(), ios::out | ios::binary); WriteValues(da, myFile); myFile.close(); @@ -559,7 +560,7 @@ std::string vtkGLTFExporter::WriteToString() void vtkGLTFExporter::WriteData() { - ofstream output; + vtksys::ofstream output; // make sure the user specified a FileName or FilePointer if (this->FileName == nullptr) diff --git a/IO/Export/vtkJSONDataSetWriter.cxx b/IO/Export/vtkJSONDataSetWriter.cxx index 984ec210aee..bef320993c9 100644 --- a/IO/Export/vtkJSONDataSetWriter.cxx +++ b/IO/Export/vtkJSONDataSetWriter.cxx @@ -32,6 +32,7 @@ #include "vtkTypeInt64Array.h" #include "vtkTypeUInt32Array.h" #include "vtkTypeUInt64Array.h" +#include "vtksys/FStream.hxx" #include "vtksys/MD5.h" #include "vtksys/SystemTools.hxx" @@ -281,7 +282,7 @@ void vtkJSONDataSetWriter::WriteData() std::stringstream scenePath; scenePath << this->FileName << "/index.json"; - ofstream file; + vtksys::ofstream file; file.open(scenePath.str().c_str(), ios::out); file << metaJsonFile.str().c_str(); file.close(); @@ -472,7 +473,7 @@ bool vtkJSONDataSetWriter::WriteArrayAsRAW(vtkDataArray* input, const char* file const char* content = (const char*)arrayToWrite->GetVoidPointer(0); size_t size = arrayToWrite->GetNumberOfValues() * arrayToWrite->GetDataTypeSize(); - ofstream file; + vtksys::ofstream file; file.open(filePath, ios::out | ios::binary); file.write(content, size); file.close(); diff --git a/IO/Export/vtkJSONSceneExporter.cxx b/IO/Export/vtkJSONSceneExporter.cxx index 40e4d8d9d12..07ef62b371a 100644 --- a/IO/Export/vtkJSONSceneExporter.cxx +++ b/IO/Export/vtkJSONSceneExporter.cxx @@ -33,6 +33,7 @@ #include "vtkRendererCollection.h" #include "vtkScalarsToColors.h" #include "vtkSmartPointer.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include <fstream> @@ -333,7 +334,7 @@ void vtkJSONSceneExporter::WriteData() std::stringstream scenePath; scenePath << this->FileName << "/index.json"; - ofstream file; + vtksys::ofstream file; file.open(scenePath.str().c_str(), ios::out); file << sceneJsonFile.str().c_str(); file.close(); diff --git a/IO/Export/vtkOBJExporter.cxx b/IO/Export/vtkOBJExporter.cxx index 15dfde3fb45..6eef6c2f604 100644 --- a/IO/Export/vtkOBJExporter.cxx +++ b/IO/Export/vtkOBJExporter.cxx @@ -36,6 +36,7 @@ #include "vtkTexture.h" #include "vtkTransform.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include <sstream> @@ -95,14 +96,14 @@ void vtkOBJExporter::WriteData() modelName = filePrefix; } - std::ofstream fpObj(objFilePath, ios::out); + vtksys::ofstream fpObj(objFilePath.c_str(), ios::out); if (!fpObj) { vtkErrorMacro(<< "unable to open " << objFilePath); return; } std::string mtlFilePath = std::string(this->FilePrefix) + ".mtl"; - std::ofstream fpMtl(mtlFilePath, ios::out); + vtksys::ofstream fpMtl(mtlFilePath.c_str(), ios::out); if (!fpMtl) { fpMtl.close(); @@ -164,8 +165,8 @@ void vtkOBJExporter::WriteData() fpMtl.close(); } -void vtkOBJExporter::WriteAnActor(vtkActor* anActor, std::ofstream& fpObj, std::ofstream& fpMtl, - std::string& modelName, int& idStart) +void vtkOBJExporter::WriteAnActor( + vtkActor* anActor, std::ostream& fpObj, std::ostream& fpMtl, std::string& modelName, int& idStart) { vtkDataSet* ds; vtkNew<vtkPolyData> pd; diff --git a/IO/Export/vtkOBJExporter.h b/IO/Export/vtkOBJExporter.h index a1d9a01dbe8..1d4a8b65c22 100644 --- a/IO/Export/vtkOBJExporter.h +++ b/IO/Export/vtkOBJExporter.h @@ -75,7 +75,7 @@ protected: void WriteData() override; void WriteAnActor( - vtkActor* anActor, std::ofstream& fpObj, std::ofstream& fpMat, std::string& modelName, int& id); + vtkActor* anActor, std::ostream& fpObj, std::ostream& fpMat, std::string& modelName, int& id); char* FilePrefix; char* OBJFileComment; char* MTLFileComment; diff --git a/IO/Export/vtkX3DExporterFIWriter.cxx b/IO/Export/vtkX3DExporterFIWriter.cxx index a88e2d115d3..42beea8b715 100644 --- a/IO/Export/vtkX3DExporterFIWriter.cxx +++ b/IO/Export/vtkX3DExporterFIWriter.cxx @@ -21,6 +21,7 @@ #include "vtkPoints.h" #include "vtkUnsignedCharArray.h" #include "vtkX3D.h" +#include "vtksys/FStream.hxx" #include <cassert> #include <sstream> @@ -106,7 +107,7 @@ int vtkX3DExporterFIByteWriter::OpenFile(const char* file) this->WriteToOutputString = 0; this->CurrentByte = 0; this->CurrentBytePos = 0; - ofstream* fileStream = new ofstream(); + vtksys::ofstream* fileStream = new vtksys::ofstream(); fileStream->open(file, ios::out | ios::binary); if (fileStream->fail()) { diff --git a/IO/Export/vtkX3DExporterXMLWriter.cxx b/IO/Export/vtkX3DExporterXMLWriter.cxx index b6cbce8c363..ca39adfe155 100644 --- a/IO/Export/vtkX3DExporterXMLWriter.cxx +++ b/IO/Export/vtkX3DExporterXMLWriter.cxx @@ -21,6 +21,7 @@ #include "vtkPoints.h" #include "vtkUnsignedCharArray.h" #include "vtkX3D.h" +#include <vtksys/FStream.hxx> #include <cassert> #include <fstream> @@ -79,7 +80,7 @@ int vtkX3DExporterXMLWriter::OpenFile(const char* file) { this->CloseFile(); this->WriteToOutputString = 0; - std::fstream* fileStream = new std::fstream(); + vtksys::ofstream* fileStream = new vtksys::ofstream(); fileStream->open(file, ios::out); if (fileStream->fail()) { diff --git a/IO/GeoJSON/vtkGeoJSONReader.cxx b/IO/GeoJSON/vtkGeoJSONReader.cxx index 09500a0f82b..c5f93705be0 100644 --- a/IO/GeoJSON/vtkGeoJSONReader.cxx +++ b/IO/GeoJSON/vtkGeoJSONReader.cxx @@ -208,7 +208,7 @@ int vtkGeoJSONReader::GeoJSONReaderInternal::CanParseFile(const char* filename, return VTK_ERROR; } - ifstream file; + vtksys::ifstream file; file.open(filename); if (!file.is_open()) diff --git a/IO/GeoJSON/vtkGeoJSONWriter.cxx b/IO/GeoJSON/vtkGeoJSONWriter.cxx index c3ae5cb27b5..c21e405a346 100644 --- a/IO/GeoJSON/vtkGeoJSONWriter.cxx +++ b/IO/GeoJSON/vtkGeoJSONWriter.cxx @@ -132,7 +132,7 @@ ostream* vtkGeoJSONWriter::OpenFile() return nullptr; } - fptr = new ofstream(this->FileName, ios::out); + fptr = new vtksys::ofstream(this->FileName, ios::out); } else { diff --git a/IO/Geometry/vtkAVSucdReader.cxx b/IO/Geometry/vtkAVSucdReader.cxx index 618d8b0eee8..f787cb494e8 100644 --- a/IO/Geometry/vtkAVSucdReader.cxx +++ b/IO/Geometry/vtkAVSucdReader.cxx @@ -35,6 +35,7 @@ #include "vtkPointData.h" #include "vtkType.h" #include "vtkUnstructuredGrid.h" +#include "vtksys/Encoding.hxx" #include <map> @@ -182,7 +183,8 @@ int vtkAVSucdReader::RequestInformation(vtkInformation* vtkNotUsed(request), } #ifdef _WIN32 - this->FileStream = new ifstream(this->FileName, ios::in | ios::binary); + std::wstring wfilename = vtksys::Encoding::ToWindowsExtendedPath(this->FileName); + this->FileStream = new ifstream(wfilename, ios::in | ios::binary); #else this->FileStream = new ifstream(this->FileName, ios::in); #endif @@ -204,7 +206,12 @@ int vtkAVSucdReader::RequestInformation(vtkInformation* vtkNotUsed(request), delete this->FileStream; // close file to reopen it later this->FileStream = nullptr; +#ifdef _WIN32 + std::wstring wfilename = vtksys::Encoding::ToWindowsExtendedPath(this->FileName); + this->FileStream = new ifstream(wfilename, ios::in); +#else this->FileStream = new ifstream(this->FileName, ios::in); +#endif char c = '\0'; while (!FileStream->eof()) { diff --git a/IO/Geometry/vtkFLUENTReader.cxx b/IO/Geometry/vtkFLUENTReader.cxx index d5ceba81116..fda39de3bf0 100644 --- a/IO/Geometry/vtkFLUENTReader.cxx +++ b/IO/Geometry/vtkFLUENTReader.cxx @@ -45,6 +45,7 @@ #include "vtkTriangle.h" #include "vtkUnstructuredGrid.h" #include "vtkWedge.h" +#include "vtksys/Encoding.hxx" #include "fstream" #include <algorithm> @@ -176,8 +177,6 @@ vtkFLUENTReader::vtkFLUENTReader() this->ScalarSubSectionIds = new intVector; this->VectorVariableNames = new stringVector; this->VectorSubSectionIds = new intVector; - this->FluentCaseFile = new ifstream; - this->FluentDataFile = new ifstream; this->NumberOfCells = 0; @@ -434,8 +433,8 @@ int vtkFLUENTReader::RequestInformation(vtkInformation* vtkNotUsed(request), bool vtkFLUENTReader::OpenCaseFile(const char* filename) { #ifdef _WIN32 - // this->FluentCaseFile->open(filename, ios::in | ios::binary); - this->FluentCaseFile = new ifstream(filename, ios::in | ios::binary); + std::wstring wfilename = vtksys::Encoding::ToWindowsExtendedPath(filename); + this->FluentCaseFile = new ifstream(wfilename, ios::in | ios::binary); #else // this->FluentCaseFile->open(filename, ios::in); this->FluentCaseFile = new ifstream(filename, ios::in); @@ -504,8 +503,8 @@ bool vtkFLUENTReader::OpenDataFile(const char* filename) dfilename.append("dat"); #ifdef _WIN32 - // this->FluentDataFile->open(dfilename.c_str(), ios::in | ios::binary); - this->FluentDataFile = new ifstream(dfilename.c_str(), ios::in | ios::binary); + this->FluentDataFile = + new ifstream(vtksys::Encoding::ToWindowsExtendedPath(dfilename), ios::in | ios::binary); #else // this->FluentDataFile->open(dfilename.c_str(), ios::in); this->FluentDataFile = new ifstream(dfilename.c_str(), ios::in); diff --git a/IO/Geometry/vtkFacetWriter.cxx b/IO/Geometry/vtkFacetWriter.cxx index 11732f8376d..d2e7eef1b56 100644 --- a/IO/Geometry/vtkFacetWriter.cxx +++ b/IO/Geometry/vtkFacetWriter.cxx @@ -29,6 +29,7 @@ #include "vtkDoubleArray.h" #include "vtkSmartPointer.h" #include "vtkUnsignedIntArray.h" +#include "vtksys/FStream.hxx" #include <string> #include <sys/stat.h> @@ -70,7 +71,7 @@ int vtkFacetWriter::RequestData(vtkInformation* vtkNotUsed(request), return 0; } - this->OutputStream = new ofstream(this->FileName); + this->OutputStream = new vtksys::ofstream(this->FileName); if (!this->OutputStream) { vtkErrorMacro("Error opening file: " << this->FileName << " for writing"); diff --git a/IO/Geometry/vtkGAMBITReader.cxx b/IO/Geometry/vtkGAMBITReader.cxx index 6fa9e10a6dc..0a967d84c2a 100644 --- a/IO/Geometry/vtkGAMBITReader.cxx +++ b/IO/Geometry/vtkGAMBITReader.cxx @@ -28,6 +28,7 @@ #include "vtkObjectFactory.h" #include "vtkPointData.h" #include "vtkUnstructuredGrid.h" +#include "vtksys/Encoding.hxx" vtkStandardNewMacro(vtkGAMBITReader); @@ -138,7 +139,11 @@ int vtkGAMBITReader::RequestInformation(vtkInformation* vtkNotUsed(request), return 0; } +#ifdef _WIN32 + this->FileStream = new ifstream(vtksys::Encoding::ToWindowsExtendedPath(this->FileName), ios::in); +#else this->FileStream = new ifstream(this->FileName, ios::in); +#endif if (this->FileStream->fail()) { diff --git a/IO/Geometry/vtkGLTFDocumentLoader.cxx b/IO/Geometry/vtkGLTFDocumentLoader.cxx index ad93704e4c7..700ba3823ba 100644 --- a/IO/Geometry/vtkGLTFDocumentLoader.cxx +++ b/IO/Geometry/vtkGLTFDocumentLoader.cxx @@ -38,6 +38,7 @@ #include "vtkQuaternion.h" #include "vtkTransform.h" #include "vtkUnsignedShortArray.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include <algorithm> @@ -1357,8 +1358,8 @@ bool vtkGLTFDocumentLoader::LoadFileBuffer( } // Open the file in binary mode - std::ifstream fin; - fin.open(fileName, std::ios::binary | std::ios::in); + vtksys::ifstream fin; + fin.open(fileName.c_str(), std::ios::binary | std::ios::in); if (!fin.is_open()) { vtkErrorMacro("Error opening file " << fileName); diff --git a/IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx b/IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx index 543bee92e6e..f06fc51c1bc 100644 --- a/IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx +++ b/IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx @@ -20,6 +20,7 @@ #include "vtkMathUtilities.h" #include "vtkTransform.h" #include "vtk_jsoncpp.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include <algorithm> @@ -36,7 +37,7 @@ bool vtkGLTFDocumentLoaderInternals::LoadBuffer( } int byteLength = 0; - ifstream fin; + vtksys::ifstream fin; std::string name = ""; vtkGLTFUtils::GetStringValue(root["name"], name); @@ -114,7 +115,7 @@ bool vtkGLTFDocumentLoaderInternals::LoadFileMetaData( } std::stringstream JSONstream; - std::ifstream fin; + vtksys::ifstream fin; if (extension == ".glb") { // Get base information @@ -134,7 +135,7 @@ bool vtkGLTFDocumentLoaderInternals::LoadFileMetaData( } // Open the file in binary mode - fin.open(fileName, std::ios::binary | std::ios::in); + fin.open(fileName.c_str(), std::ios::binary | std::ios::in); if (!fin.is_open()) { vtkErrorWithObjectMacro(this->Self, "Error opening file " << fileName); @@ -152,7 +153,7 @@ bool vtkGLTFDocumentLoaderInternals::LoadFileMetaData( else { // Copy whole file into string - fin.open(fileName); + fin.open(fileName.c_str()); if (!fin.is_open()) { vtkErrorWithObjectMacro(this->Self, "Error opening file " << fileName); diff --git a/IO/Geometry/vtkGLTFUtils.cxx b/IO/Geometry/vtkGLTFUtils.cxx index edd4cf61959..56e4add5619 100644 --- a/IO/Geometry/vtkGLTFUtils.cxx +++ b/IO/Geometry/vtkGLTFUtils.cxx @@ -17,6 +17,7 @@ #include "vtkBase64Utilities.h" #include "vtk_jsoncpp.h" +#include "vtksys/FStream.hxx" #include "vtksys/RegularExpression.hxx" #include "vtksys/SystemTools.hxx" @@ -253,12 +254,12 @@ bool vtkGLTFUtils::GetBinaryBufferFromUri(const std::string& uri, const std::str // Load buffer from file else { - ifstream fin; + vtksys::ifstream fin; std::string bufferPath = GetResourceFullPath(uri, glTFFilePath); // Open file - fin.open(bufferPath, ios::binary); + fin.open(bufferPath.c_str(), ios::binary); if (!fin.is_open()) { return false; @@ -282,8 +283,8 @@ bool vtkGLTFUtils::GetBinaryBufferFromUri(const std::string& uri, const std::str bool vtkGLTFUtils::ExtractGLBFileInformation(const std::string& fileName, std::string& magic, uint32_t& version, uint32_t& fileLength, std::vector<vtkGLTFUtils::ChunkInfoType>& chunkInfo) { - std::ifstream fin; - fin.open(fileName, std::ios::binary | std::ios::in); + vtksys::ifstream fin; + fin.open(fileName.c_str(), std::ios::binary | std::ios::in); if (!fin.is_open()) { return false; diff --git a/IO/Geometry/vtkHoudiniPolyDataWriter.cxx b/IO/Geometry/vtkHoudiniPolyDataWriter.cxx index a590f6aa0af..5ee0bc34420 100644 --- a/IO/Geometry/vtkHoudiniPolyDataWriter.cxx +++ b/IO/Geometry/vtkHoudiniPolyDataWriter.cxx @@ -40,6 +40,7 @@ #include "vtkUnsignedLongArray.h" #include "vtkUnsignedLongLongArray.h" #include "vtkUnsignedShortArray.h" +#include "vtksys/FStream.hxx" vtkStandardNewMacro(vtkHoudiniPolyDataWriter); @@ -307,7 +308,7 @@ void vtkHoudiniPolyDataWriter::WriteData() } // Open the file for streaming - std::ofstream file(this->FileName, std::ofstream::out); + vtksys::ofstream file(this->FileName, vtksys::ofstream::out); if (file.fail()) { diff --git a/IO/Geometry/vtkMFIXReader.cxx b/IO/Geometry/vtkMFIXReader.cxx index 68219b69728..342f9caebf0 100644 --- a/IO/Geometry/vtkMFIXReader.cxx +++ b/IO/Geometry/vtkMFIXReader.cxx @@ -36,6 +36,7 @@ #include "vtkStringArray.h" #include "vtkUnstructuredGrid.h" #include "vtkWedge.h" +#include "vtksys/FStream.hxx" #include <string> vtkStandardNewMacro(vtkMFIXReader); @@ -899,9 +900,9 @@ void vtkMFIXReader::ReadRestartFile() int dimensionUsr = 5; #ifdef _WIN32 - ifstream in(this->FileName, ios::binary); + vtksys::ifstream in(this->FileName, ios::binary); #else - ifstream in(this->FileName); + vtksys::ifstream in(this->FileName); #endif if (!in) @@ -1613,9 +1614,9 @@ void vtkMFIXReader::CreateVariableNames() } #ifdef _WIN32 - ifstream in(fileName, ios::binary); + vtksys::ifstream in(fileName, ios::binary); #else - ifstream in(fileName); + vtksys::ifstream in(fileName); #endif if (in) // file exists { @@ -1932,9 +1933,9 @@ void vtkMFIXReader::GetTimeSteps() strcat(fileName, ".SPB"); } #ifdef _WIN32 - ifstream in(fileName, ios::binary); + vtksys::ifstream in(fileName, ios::binary); #else - ifstream in(fileName); + vtksys::ifstream in(fileName); #endif int numberOfVariables = 0; @@ -2133,9 +2134,9 @@ void vtkMFIXReader::GetVariableAtTimestep(int vari, int tstep, vtkFloatArray* v) int index = (vari * this->MaximumTimestep) + tstep; int nBytesSkip = this->SPXTimestepIndexTable->GetValue(index); #ifdef _WIN32 - ifstream in(fileName, ios::binary); + vtksys::ifstream in(fileName, ios::binary); #else - ifstream in(fileName); + vtksys::ifstream in(fileName); #endif in.seekg(nBytesSkip, ios::beg); this->GetBlockOfFloats(in, v, this->IJKMaximum2); @@ -2335,9 +2336,9 @@ void vtkMFIXReader::GetAllTimes(vtkInformationVector* outputVector) } #ifdef _WIN32 - ifstream tfile(fileName, ios::binary); + vtksys::ifstream tfile(fileName, ios::binary); #else - ifstream tfile(fileName); + vtksys::ifstream tfile(fileName); #endif int numberOfVariablesInSPX = diff --git a/IO/Geometry/vtkOBJWriter.cxx b/IO/Geometry/vtkOBJWriter.cxx index 6657f5cb2c4..1f79d99b80f 100644 --- a/IO/Geometry/vtkOBJWriter.cxx +++ b/IO/Geometry/vtkOBJWriter.cxx @@ -25,12 +25,13 @@ #include "vtkSmartPointer.h" #include "vtkTriangleStrip.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" namespace { //---------------------------------------------------------------------------- -void WriteFaces(std::ofstream& f, vtkCellArray* faces, bool withNormals, bool withTCoords) +void WriteFaces(std::ostream& f, vtkCellArray* faces, bool withNormals, bool withTCoords) { vtkIdType npts; const vtkIdType* indx; @@ -58,7 +59,7 @@ void WriteFaces(std::ofstream& f, vtkCellArray* faces, bool withNormals, bool wi } //---------------------------------------------------------------------------- -void WriteLines(std::ofstream& f, vtkCellArray* lines) +void WriteLines(std::ostream& f, vtkCellArray* lines) { vtkIdType npts; const vtkIdType* indx; @@ -74,7 +75,7 @@ void WriteLines(std::ofstream& f, vtkCellArray* lines) } //---------------------------------------------------------------------------- -void WritePoints(std::ofstream& f, vtkPoints* pts, vtkDataArray* normals, vtkDataArray* tcoords) +void WritePoints(std::ostream& f, vtkPoints* pts, vtkDataArray* normals, vtkDataArray* tcoords) { vtkNumberToString convert; vtkIdType nbPts = pts->GetNumberOfPoints(); @@ -111,10 +112,10 @@ void WritePoints(std::ofstream& f, vtkPoints* pts, vtkDataArray* normals, vtkDat } //---------------------------------------------------------------------------- -bool WriteTexture(std::ofstream& f, const std::string& baseName, vtkImageData* texture) +bool WriteTexture(std::ostream& f, const std::string& baseName, vtkImageData* texture) { std::string mtlName = baseName + ".mtl"; - std::ofstream fmtl(mtlName, std::ofstream::out); + vtksys::ofstream fmtl(mtlName.c_str(), vtksys::ofstream::out); if (fmtl.fail()) { return false; @@ -195,7 +196,7 @@ void vtkOBJWriter::WriteData() vtkIdType npts = 0; - std::ofstream f(this->FileName, std::ofstream::out); + vtksys::ofstream f(this->FileName, vtksys::ofstream::out); if (f.fail()) { vtkErrorMacro("Unable to open file: " << this->FileName); diff --git a/IO/Geometry/vtkPTSReader.cxx b/IO/Geometry/vtkPTSReader.cxx index 91caeaf5af3..0a460539f43 100644 --- a/IO/Geometry/vtkPTSReader.cxx +++ b/IO/Geometry/vtkPTSReader.cxx @@ -26,6 +26,7 @@ #include "vtkPoints.h" #include "vtkPolyData.h" #include "vtkUnsignedCharArray.h" +#include "vtksys/FStream.hxx" vtkStandardNewMacro(vtkPTSReader); @@ -150,7 +151,7 @@ int vtkPTSReader::RequestData(vtkInformation* vtkNotUsed(request), // Open the new file. vtkDebugMacro(<< "Opening file " << this->FileName); - ifstream file(this->FileName, ios::in | ios::binary); + vtksys::ifstream file(this->FileName, ios::in | ios::binary); if (!file || file.fail()) { vtkErrorMacro(<< "Could not open file " << this->FileName); diff --git a/IO/Geometry/vtkParticleReader.cxx b/IO/Geometry/vtkParticleReader.cxx index ab21c61550c..0362046598f 100644 --- a/IO/Geometry/vtkParticleReader.cxx +++ b/IO/Geometry/vtkParticleReader.cxx @@ -27,6 +27,7 @@ #include "vtkPolyData.h" #include "vtkSmartPointer.h" #include "vtkStreamingDemandDrivenPipeline.h" +#include "vtksys/Encoding.hxx" #include <algorithm> #include <sstream> @@ -163,7 +164,8 @@ void vtkParticleReader::OpenFile() // Open the new file. vtkDebugMacro(<< "Initialize: opening file " << this->FileName); #ifdef _WIN32 - this->File = new ifstream(this->FileName, ios::in | ios::binary); + this->File = + new ifstream(vtksys::Encoding::ToWindowsExtendedPath(this->FileName), ios::in | ios::binary); #else this->File = new ifstream(this->FileName, ios::in); #endif diff --git a/IO/Geometry/vtkWindBladeReader.cxx b/IO/Geometry/vtkWindBladeReader.cxx index b23b8422ed3..f8c25b9150e 100644 --- a/IO/Geometry/vtkWindBladeReader.cxx +++ b/IO/Geometry/vtkWindBladeReader.cxx @@ -35,6 +35,7 @@ PURPOSE. See the above copyright notice for more information. #include "vtkToolkits.h" #include "vtkUnstructuredGrid.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include <algorithm> @@ -592,7 +593,7 @@ bool vtkWindBladeReader::ReadGlobalData() std::string fileName = this->Filename; vtksys::SystemTools::ConvertToUnixSlashes(fileName); - std::ifstream inStrStream(fileName.c_str()); + vtksys::ifstream inStrStream(fileName.c_str()); std::stringstream inStr; std::copy(std::istreambuf_iterator<char>(inStrStream), std::istreambuf_iterator<char>(), std::ostreambuf_iterator<char>(inStr)); @@ -1115,7 +1116,7 @@ void vtkWindBladeReader::SetupBladeData() fileName << this->RootDirectory << "/" << this->TurbineDirectory << "/" << this->TurbineTowerName; char inBuf[LINE_SIZE]; - ifstream inStr(fileName.str().c_str()); + vtksys::ifstream inStr(fileName.str().c_str()); if (!inStr) { @@ -1135,7 +1136,7 @@ void vtkWindBladeReader::SetupBladeData() fileName2 << this->RootDirectory << "/" << this->TurbineDirectory << "/" << this->TurbineBladeName << this->TimeStepFirst; - ifstream inStr2(fileName2.str().c_str()); + vtksys::ifstream inStr2(fileName2.str().c_str()); if (!inStr2) { @@ -1200,7 +1201,7 @@ void vtkWindBladeReader::LoadBladeData(int timeStep) fileName << this->RootDirectory << "/" << this->TurbineDirectory << "/" << this->TurbineBladeName << this->TimeSteps[timeStep]; - std::ifstream inStr(fileName.str().c_str()); + vtksys::ifstream inStr(fileName.str().c_str()); std::stringstream inStrSS; std::copy(std::istreambuf_iterator<char>(inStr), std::istreambuf_iterator<char>(), std::ostreambuf_iterator<char>(inStrSS)); diff --git a/IO/Image/Testing/Cxx/TestPNGReaderReadFromMemory.cxx b/IO/Image/Testing/Cxx/TestPNGReaderReadFromMemory.cxx index 719bb933318..3deb7215676 100644 --- a/IO/Image/Testing/Cxx/TestPNGReaderReadFromMemory.cxx +++ b/IO/Image/Testing/Cxx/TestPNGReaderReadFromMemory.cxx @@ -20,6 +20,7 @@ #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkRenderer.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include <fstream> @@ -37,7 +38,7 @@ int TestPNGReaderReadFromMemory(int argc, char* argv[]) std::string filename = argv[1]; // Open the file - std::ifstream stream(filename, std::ios::in | std::ios::binary); + vtksys::ifstream stream(filename.c_str(), std::ios::in | std::ios::binary); if (!stream.is_open()) { std::cerr << "Could not open file " << filename.c_str() << std::endl; diff --git a/IO/Image/vtkImageReader2.cxx b/IO/Image/vtkImageReader2.cxx index b28f157c42c..a324ae6da56 100644 --- a/IO/Image/vtkImageReader2.cxx +++ b/IO/Image/vtkImageReader2.cxx @@ -25,6 +25,7 @@ #include "vtkStreamingDemandDrivenPipeline.h" #include "vtkStringArray.h" +#include "vtksys/Encoding.hxx" #include "vtksys/SystemTools.hxx" vtkStandardNewMacro(vtkImageReader2); @@ -575,7 +576,8 @@ int vtkImageReader2::OpenFile() if (!vtksys::SystemTools::Stat(this->InternalFileName, &fs)) { #ifdef _WIN32 - this->File = new ifstream(this->InternalFileName, ios::in | ios::binary); + std::wstring wfilename = vtksys::Encoding::ToWindowsExtendedPath(this->InternalFileName); + this->File = new ifstream(wfilename, ios::in | ios::binary); #else this->File = new ifstream(this->InternalFileName, ios::in); #endif diff --git a/IO/Image/vtkImageWriter.cxx b/IO/Image/vtkImageWriter.cxx index 32c29cab972..d0bd97ce295 100644 --- a/IO/Image/vtkImageWriter.cxx +++ b/IO/Image/vtkImageWriter.cxx @@ -24,6 +24,7 @@ #include "vtkPointData.h" #include "vtkStreamingDemandDrivenPipeline.h" +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> vtkStandardNewMacro(vtkImageWriter); @@ -195,7 +196,7 @@ void vtkImageWriter::RecursiveWrite( } // Open the file #ifdef _WIN32 - file = new ofstream(this->InternalFileName, ios::out | ios::binary); + file = new vtksys::ofstream(this->InternalFileName, ios::out | ios::binary); #else file = new ofstream(this->InternalFileName, ios::out); #endif @@ -321,7 +322,7 @@ void vtkImageWriter::RecursiveWrite( } // Open the file #ifdef _WIN32 - file = new ofstream(this->InternalFileName, ios::out | ios::binary); + file = new vtksys::ofstream(this->InternalFileName, ios::out | ios::binary); #else file = new ofstream(this->InternalFileName, ios::out); #endif diff --git a/IO/Image/vtkJSONImageWriter.cxx b/IO/Image/vtkJSONImageWriter.cxx index eafe45a66bb..2aa332edbe2 100644 --- a/IO/Image/vtkJSONImageWriter.cxx +++ b/IO/Image/vtkJSONImageWriter.cxx @@ -26,6 +26,7 @@ #include "vtkPointData.h" #include "vtkStreamingDemandDrivenPipeline.h" +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> vtkStandardNewMacro(vtkJSONImageWriter); @@ -80,7 +81,7 @@ int vtkJSONImageWriter::RequestData(vtkInformation* vtkNotUsed(request), vtkCharArray* validMask = vtkArrayDownCast<vtkCharArray>(input->GetPointData()->GetArray("vtkValidPointMask")); - ofstream file(this->FileName, ios::out); + vtksys::ofstream file(this->FileName, ios::out); if (file.fail()) { vtkErrorMacro("RecursiveWrite: Could not open file " << this->FileName); diff --git a/IO/Image/vtkMRCReader.cxx b/IO/Image/vtkMRCReader.cxx index 5b8d81ea921..4fd7757668e 100644 --- a/IO/Image/vtkMRCReader.cxx +++ b/IO/Image/vtkMRCReader.cxx @@ -31,6 +31,7 @@ #include "vtkTypeInt16Array.h" #include "vtkTypeInt8Array.h" #include "vtkTypeUInt16Array.h" +#include "vtksys/FStream.hxx" #include <cassert> @@ -130,7 +131,7 @@ std::ostream& operator<<(std::ostream& os, const mrc_file_header& hdr) class vtkMRCReader::vtkInternal { public: - ifstream* stream; + vtksys::ifstream* stream; mrc_file_header header; vtkInternal() @@ -144,7 +145,7 @@ public: void openFile(const char* file) { delete stream; - stream = new std::ifstream(file, std::ifstream::binary); + stream = new vtksys::ifstream(file, std::ios::binary); } }; @@ -317,7 +318,8 @@ ByteSwapFunction getByteSwapFunction(int vtkType, bool isLittleEndian) template <typename T> void readData(int numComponents, int* outExt, vtkIdType* outInc, vtkIdType* inOffsets, - T* const outPtr, std::ifstream& stream, vtkIdType dataStartPos, ByteSwapFunction byteSwapFunction) + T* const outPtr, vtksys::ifstream& stream, vtkIdType dataStartPos, + ByteSwapFunction byteSwapFunction) { vtkIdType lineSize = (outExt[1] - outExt[0] + 1) * numComponents; T* ptr = outPtr; @@ -329,7 +331,7 @@ void readData(int numComponents, int* outExt, vtkIdType* outInc, vtkIdType* inOf vtkIdType offset = z * inOffsets[2] + y * inOffsets[1] + outExt[0] * inOffsets[0]; offset = dataStartPos + offset * sizeof(T); - stream.seekg(offset, std::ifstream::beg); + stream.seekg(offset, vtksys::ifstream::beg); // read the line stream.read((char*)ptr, lineSize * sizeof(T)); if (byteSwapFunction) @@ -378,7 +380,7 @@ void vtkMRCReader::ExecuteDataWithInformation( } // data start position is 1024 (the header size) plus the extended header size vtkIdType dataStartPos = 1024 + this->Internals->header.next; - this->Internals->stream->seekg(dataStartPos, std::ifstream::beg); + this->Internals->stream->seekg(dataStartPos, vtksys::ifstream::beg); int vtkType = getFileDataType(this->Internals->header.mode); int numComponents = getFileDataNumComponents(this->Internals->header.mode); diff --git a/IO/Image/vtkMetaImageReader.cxx b/IO/Image/vtkMetaImageReader.cxx index 9b01b738ec3..74d4f58553b 100644 --- a/IO/Image/vtkMetaImageReader.cxx +++ b/IO/Image/vtkMetaImageReader.cxx @@ -25,6 +25,7 @@ #include "vtkObjectFactory.h" #include "vtkPointData.h" #include "vtkStreamingDemandDrivenPipeline.h" +#include "vtksys/FStream.hxx" #include "vtkmetaio/metaEvent.h" #include "vtkmetaio/metaImage.h" @@ -280,7 +281,7 @@ int vtkMetaImageReader::CanReadFile(const char* fname) } // Now check the file content - ifstream inputStream; + vtksys::ifstream inputStream; inputStream.open(fname, ios::in | ios::binary); diff --git a/IO/Image/vtkNrrdReader.cxx b/IO/Image/vtkNrrdReader.cxx index bdbaa2de52b..481dcfbfe57 100644 --- a/IO/Image/vtkNrrdReader.cxx +++ b/IO/Image/vtkNrrdReader.cxx @@ -31,6 +31,7 @@ #include <sstream> #include <string> #include <vector> +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> #include <cctype> @@ -238,7 +239,7 @@ void vtkNrrdReader::PrintSelf(ostream& os, vtkIndent indent) //----------------------------------------------------------------------------- int vtkNrrdReader::CanReadFile(const char* filename) { - ifstream file(filename, ios::in | ios::binary); + vtksys::ifstream file(filename, ios::in | ios::binary); std::string firstLine; getline(file, firstLine); if (firstLine.substr(0, 4) == "NRRD") @@ -270,7 +271,7 @@ int vtkNrrdReader::ReadHeaderInternal(vtkCharArray* headerBuffer) return 0; } - ifstream file(this->FileName, ios::in | ios::binary); + vtksys::ifstream file(this->FileName, ios::in | ios::binary); // Read in 4 MB. Assuming that the header will be smaller than that. headerBuffer->SetNumberOfTuples(0x400000); file.read(headerBuffer->GetPointer(0), 0x400000 - 1); @@ -699,7 +700,7 @@ int vtkNrrdReaderReadDataAsciiTemplate(vtkNrrdReader* self, vtkImageData* output vtkStringArray* filenames = self->GetFileNames(); vtkStdString filename = self->GetFileName(); - std::ifstream file; + vtksys::ifstream file; if (self->GetFileDimensionality() == 3) { if (filenames != nullptr) diff --git a/IO/Image/vtkSEPReader.cxx b/IO/Image/vtkSEPReader.cxx index cd654df3e66..b20a30200ae 100644 --- a/IO/Image/vtkSEPReader.cxx +++ b/IO/Image/vtkSEPReader.cxx @@ -15,6 +15,7 @@ #include "vtkInformationVector.h" #include "vtkObjectFactory.h" #include "vtkUnstructuredGrid.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include <iostream> @@ -113,7 +114,7 @@ int vtkSEPReader::ReadHeader() return 0; } - ifstream file(this->FileName, ios::in | ios::binary); + vtksys::ifstream file(this->FileName, ios::in | ios::binary); if (file.fail()) { vtkErrorMacro(<< "Could not open file " << this->FileName); diff --git a/IO/Import/vtkOBJImporterInternals.cxx b/IO/Import/vtkOBJImporterInternals.cxx index addae8b34fa..15d6a4f7550 100644 --- a/IO/Import/vtkOBJImporterInternals.cxx +++ b/IO/Import/vtkOBJImporterInternals.cxx @@ -23,6 +23,7 @@ #include "vtkTIFFReader.h" #include "vtkTexture.h" #include "vtkTransform.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include <cstdio> @@ -256,7 +257,7 @@ std::vector<vtkOBJImportedMaterial*> vtkOBJPolyDataProcessor::ParseOBJandMTL( return listOfMaterials; } - std::ifstream in(Filename, std::ios::in | std::ios::binary); + vtksys::ifstream in(Filename.c_str(), std::ios::in | std::ios::binary); if (!in) { return listOfMaterials; diff --git a/IO/Infovis/vtkBiomTableReader.cxx b/IO/Infovis/vtkBiomTableReader.cxx index 50dcc364454..8cf16a4c77c 100644 --- a/IO/Infovis/vtkBiomTableReader.cxx +++ b/IO/Infovis/vtkBiomTableReader.cxx @@ -27,6 +27,7 @@ #include "vtkStringArray.h" #include "vtkTable.h" #include "vtkVariantArray.h" +#include "vtksys/FStream.hxx" #include <algorithm> #include <sstream> @@ -80,7 +81,7 @@ int vtkBiomTableReader::ReadMeshSimple(const std::string& fname, vtkDataObject* return 1; } - std::ifstream ifs(fname, std::ifstream::in); + vtksys::ifstream ifs(fname.c_str(), vtksys::ifstream::in); if (!ifs.good()) { vtkErrorMacro(<< "Unable to open " << fname << " for reading"); diff --git a/IO/Infovis/vtkChacoGraphReader.cxx b/IO/Infovis/vtkChacoGraphReader.cxx index f3f850282c0..1e9694ca88c 100644 --- a/IO/Infovis/vtkChacoGraphReader.cxx +++ b/IO/Infovis/vtkChacoGraphReader.cxx @@ -50,6 +50,7 @@ #include "vtkPointData.h" #include "vtkSmartPointer.h" #include "vtkStdString.h" +#include "vtksys/FStream.hxx" #include <fstream> #include <sstream> @@ -93,7 +94,7 @@ int vtkChacoGraphReader::RequestData(vtkInformation* vtkNotUsed(request), return 0; } - std::ifstream fin(this->FileName); + vtksys::ifstream fin(this->FileName); if (!fin.is_open()) { vtkErrorMacro("Could not open file " << this->FileName << "."); diff --git a/IO/Infovis/vtkDIMACSGraphReader.cxx b/IO/Infovis/vtkDIMACSGraphReader.cxx index 8222a277615..f573352205b 100644 --- a/IO/Infovis/vtkDIMACSGraphReader.cxx +++ b/IO/Infovis/vtkDIMACSGraphReader.cxx @@ -34,7 +34,7 @@ #include <fstream> #include <iostream> #include <sstream> -using std::ifstream; +#include <vtksys/FStream.hxx> using std::istringstream; #define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New() @@ -144,7 +144,7 @@ int vtkDIMACSGraphReader::buildGenericGraph(vtkGraph* output, // set starting edge id number. int baseEdgeId = 1; - ifstream IFP(this->FileName); + vtksys::ifstream IFP(this->FileName); if (IFP.is_open()) { while (vtksys::SystemTools::GetLineFromStream(IFP, S)) @@ -264,7 +264,7 @@ int vtkDIMACSGraphReader::buildMaxflowGraph(vtkGraph* output) // set starting edge id number. int baseEdgeId = 1; - ifstream IFP(this->FileName); + vtksys::ifstream IFP(this->FileName); if (IFP.is_open()) { while (vtksys::SystemTools::GetLineFromStream(IFP, S)) @@ -369,7 +369,7 @@ int vtkDIMACSGraphReader::buildColoringGraph(vtkGraph* output) // set starting edge id number. int baseEdgeId = 1; - ifstream IFP(this->FileName); + vtksys::ifstream IFP(this->FileName); if (IFP.is_open()) { while (vtksys::SystemTools::GetLineFromStream(IFP, S)) @@ -426,7 +426,7 @@ int vtkDIMACSGraphReader::ReadGraphMetaData() return 0; } - ifstream IFP(this->FileName); + vtksys::ifstream IFP(this->FileName); if (!IFP.is_open()) { vtkErrorMacro("Could not open file " << this->FileName << "."); diff --git a/IO/Infovis/vtkDelimitedTextReader.cxx b/IO/Infovis/vtkDelimitedTextReader.cxx index 3e6b35aa5e1..417d696ad7b 100644 --- a/IO/Infovis/vtkDelimitedTextReader.cxx +++ b/IO/Infovis/vtkDelimitedTextReader.cxx @@ -34,6 +34,7 @@ #include "vtkTextCodec.h" #include "vtkTextCodecFactory.h" +#include "vtksys/FStream.hxx" #include <algorithm> #include <iostream> @@ -572,7 +573,7 @@ int vtkDelimitedTextReader::RequestData( } istream* input_stream_pt = nullptr; - ifstream file_stream; + vtksys::ifstream file_stream; std::istringstream string_stream; if (!this->ReadFromInputString) diff --git a/IO/Infovis/vtkFixedWidthTextReader.cxx b/IO/Infovis/vtkFixedWidthTextReader.cxx index 0fa5b17ad11..1cbaa88ae12 100644 --- a/IO/Infovis/vtkFixedWidthTextReader.cxx +++ b/IO/Infovis/vtkFixedWidthTextReader.cxx @@ -28,6 +28,7 @@ #include "vtkStringArray.h" #include "vtkTable.h" #include "vtkVariantArray.h" +#include "vtksys/FStream.hxx" #include <algorithm> #include <fstream> @@ -97,7 +98,7 @@ int vtkFixedWidthTextReader::RequestData( return 2; } - std::ifstream infile(this->FileName, ios::in); + vtksys::ifstream infile(this->FileName, ios::in); if (!infile || infile.fail()) { vtkErrorMacro(<< "vtkFixedWidthTextReader: Couldn't open file!"); diff --git a/IO/Infovis/vtkISIReader.cxx b/IO/Infovis/vtkISIReader.cxx index b4dac07e4bf..026e6208ce4 100644 --- a/IO/Infovis/vtkISIReader.cxx +++ b/IO/Infovis/vtkISIReader.cxx @@ -25,6 +25,7 @@ #include "vtkStringArray.h" #include "vtkTable.h" #include "vtkVariant.h" +#include "vtksys/FStream.hxx" #include <map> #include <string> @@ -79,7 +80,7 @@ int vtkISIReader::RequestData( } // Open the file - ifstream file(this->FileName, ios::in | ios::binary); + vtksys::ifstream file(this->FileName, ios::in | ios::binary); if (!file) { vtkErrorMacro(<< "vtkISIReader could not open file " << this->FileName); diff --git a/IO/Infovis/vtkMultiNewickTreeReader.cxx b/IO/Infovis/vtkMultiNewickTreeReader.cxx index 3b1ae804617..2e07cd4d89a 100644 --- a/IO/Infovis/vtkMultiNewickTreeReader.cxx +++ b/IO/Infovis/vtkMultiNewickTreeReader.cxx @@ -25,6 +25,7 @@ #include "vtkStreamingDemandDrivenPipeline.h" #include "vtkStringArray.h" #include "vtkTree.h" +#include "vtksys/FStream.hxx" #include <fstream> #include <iostream> @@ -78,7 +79,7 @@ int vtkMultiNewickTreeReader::ReadMeshSimple(const std::string& fname, vtkDataOb return 1; } - std::ifstream ifs(fname.c_str(), std::ifstream::in); + vtksys::ifstream ifs(fname.c_str(), vtksys::ifstream::in); if (!ifs.good()) { vtkErrorMacro(<< "Unable to open " << fname << " for reading"); diff --git a/IO/Infovis/vtkNewickTreeReader.cxx b/IO/Infovis/vtkNewickTreeReader.cxx index 038f684879a..9d332a0cf9d 100644 --- a/IO/Infovis/vtkNewickTreeReader.cxx +++ b/IO/Infovis/vtkNewickTreeReader.cxx @@ -28,6 +28,7 @@ #include "vtkStringArray.h" #include "vtkTree.h" #include "vtkTreeDFSIterator.h" +#include "vtksys/FStream.hxx" #include <fstream> #include <iostream> @@ -158,7 +159,7 @@ int vtkNewickTreeReader::ReadMeshSimple(const std::string& fname, vtkDataObject* return 1; } - std::ifstream ifs(fname, std::ifstream::in); + vtksys::ifstream ifs(fname.c_str(), vtksys::ifstream::in); if (!ifs.good()) { vtkErrorMacro(<< "Unable to open " << fname << " for reading"); diff --git a/IO/Infovis/vtkRISReader.cxx b/IO/Infovis/vtkRISReader.cxx index 2a9c60c1946..0b0b11692f9 100644 --- a/IO/Infovis/vtkRISReader.cxx +++ b/IO/Infovis/vtkRISReader.cxx @@ -25,6 +25,7 @@ #include "vtkStringArray.h" #include "vtkTable.h" #include "vtkVariant.h" +#include "vtksys/FStream.hxx" #include <map> #include <string> @@ -79,7 +80,7 @@ int vtkRISReader::RequestData( } // Open the file - ifstream file(this->FileName, ios::in | ios::binary); + vtksys::ifstream file(this->FileName, ios::in | ios::binary); if (!file) { vtkErrorMacro(<< "vtkRISReader could not open file " << this->FileName); diff --git a/IO/Infovis/vtkTulipReader.cxx b/IO/Infovis/vtkTulipReader.cxx index 286eb355e39..908911c1e58 100644 --- a/IO/Infovis/vtkTulipReader.cxx +++ b/IO/Infovis/vtkTulipReader.cxx @@ -37,6 +37,7 @@ #include "vtkStdString.h" #include "vtkStringArray.h" #include "vtkVariantArray.h" +#include "vtksys/FStream.hxx" #include <cassert> #include <cctype> @@ -203,7 +204,7 @@ int vtkTulipReader::RequestData(vtkInformation* vtkNotUsed(request), return 0; } - std::ifstream fin(this->FileName); + vtksys::ifstream fin(this->FileName); if (!fin.is_open()) { vtkErrorMacro("Could not open file " << this->FileName << "."); diff --git a/IO/Infovis/vtkXGMLReader.cxx b/IO/Infovis/vtkXGMLReader.cxx index 882ca96ead9..9401380709a 100644 --- a/IO/Infovis/vtkXGMLReader.cxx +++ b/IO/Infovis/vtkXGMLReader.cxx @@ -33,6 +33,7 @@ PURPOSE. See the above copyright notice for more information. #include "vtkSmartPointer.h" #include "vtkStdString.h" #include "vtkStringArray.h" +#include "vtksys/FStream.hxx" #include <cassert> #include <cctype> // for isspace, isdigit @@ -189,7 +190,7 @@ int vtkXGMLReader::RequestData(vtkInformation* vtkNotUsed(request), return 0; } - std::ifstream fin(this->FileName); + vtksys::ifstream fin(this->FileName); if (!fin.is_open()) { vtkErrorMacro("Could not open file " << this->FileName << "."); diff --git a/IO/LAS/vtkLASReader.cxx b/IO/LAS/vtkLASReader.cxx index 0ec827de150..b8716759117 100644 --- a/IO/LAS/vtkLASReader.cxx +++ b/IO/LAS/vtkLASReader.cxx @@ -60,7 +60,7 @@ int vtkLASReader::RequestData(vtkInformation* vtkNotUsed(request), vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); // Open LAS File for reading - std::ifstream ifs; + vtksys::ifstream ifs; ifs.open(this->FileName, std::ios_base::binary | std::ios_base::in); if (!ifs.is_open()) diff --git a/IO/LSDyna/vtkLSDynaReader.cxx b/IO/LSDyna/vtkLSDynaReader.cxx index d82342c34ee..96831d130ba 100644 --- a/IO/LSDyna/vtkLSDynaReader.cxx +++ b/IO/LSDyna/vtkLSDynaReader.cxx @@ -46,6 +46,7 @@ #include "vtkLSDynaPartCollection.h" #include "vtkLSDynaSummaryParser.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #include <algorithm> @@ -150,7 +151,7 @@ static const char* vtkLSDynaCellTypes[] = { "Point", "Beam", "Shell", "Thick She // - not a comment // is encountered. Return with that text stored in \a line. // If an error or EOF is hit, return 0. Otherwise, return 1. -static int vtkLSNextSignificantLine(ifstream& deck, std::string& line) +static int vtkLSNextSignificantLine(istream& deck, std::string& line) { while (deck.good()) { @@ -3166,7 +3167,7 @@ int vtkLSDynaReader::ReadInputDeck() return 0; } - ifstream deck(this->InputDeck, ios::in); + vtksys::ifstream deck(this->InputDeck, ios::in); if (!deck.good()) { return 0; @@ -3188,7 +3189,7 @@ int vtkLSDynaReader::ReadInputDeck() return retval; } -int vtkLSDynaReader::ReadInputDeckXML(ifstream& deck) +int vtkLSDynaReader::ReadInputDeckXML(istream& deck) { vtkLSDynaSummaryParser* parser = vtkLSDynaSummaryParser::New(); parser->MetaData = this->P; @@ -3204,7 +3205,7 @@ int vtkLSDynaReader::ReadInputDeckXML(ifstream& deck) return 0; } -int vtkLSDynaReader::ReadInputDeckKeywords(ifstream& deck) +int vtkLSDynaReader::ReadInputDeckKeywords(istream& deck) { int success = 1; std::map<std::string, int> parameters; @@ -3372,7 +3373,7 @@ int vtkLSDynaReader::ReadInputDeckKeywords(ifstream& deck) int vtkLSDynaReader::WriteInputDeckSummary(const char* fname) { - ofstream xmlSummary(fname, ios::out | ios::trunc); + vtksys::ofstream xmlSummary(fname, ios::out | ios::trunc); if (!xmlSummary.good()) { return 1; diff --git a/IO/LSDyna/vtkLSDynaReader.h b/IO/LSDyna/vtkLSDynaReader.h index 811eba3065d..d59a4e9a6af 100644 --- a/IO/LSDyna/vtkLSDynaReader.h +++ b/IO/LSDyna/vtkLSDynaReader.h @@ -650,8 +650,8 @@ protected: * ReadInputDeck determines the type of file (keyword or XML summary) and * calls one of these two routines to read the file. */ - int ReadInputDeckXML(ifstream& deck); - int ReadInputDeckKeywords(ifstream& deck); + int ReadInputDeckXML(istream& deck); + int ReadInputDeckKeywords(istream& deck); //@} /** diff --git a/IO/Legacy/vtkDataReader.cxx b/IO/Legacy/vtkDataReader.cxx index 41328fd2eb7..d449cb39bab 100644 --- a/IO/Legacy/vtkDataReader.cxx +++ b/IO/Legacy/vtkDataReader.cxx @@ -58,6 +58,7 @@ #include "vtkUnsignedShortArray.h" #include "vtkVariantArray.h" +#include "vtksys/FStream.hxx" #include <vtksys/SystemTools.hxx> #include <algorithm> @@ -500,7 +501,7 @@ int vtkDataReader::OpenVTKFile(const char* fname) return 0; } - this->IS = new ifstream(fname, ios::in | ios::binary); + this->IS = new vtksys::ifstream(fname, ios::in | ios::binary); if (this->IS->fail()) { vtkErrorMacro(<< "Unable to open file: " << fname); @@ -613,9 +614,9 @@ int vtkDataReader::ReadHeader(const char* fname) delete this->IS; this->IS = nullptr; #ifdef _WIN32 - this->IS = new ifstream(fname, ios::in | ios::binary); + this->IS = new vtksys::ifstream(fname, ios::in | ios::binary); #else - this->IS = new ifstream(fname, ios::in); + this->IS = new vtksys::ifstream(fname, ios::in); #endif if (this->IS->fail()) { diff --git a/IO/Legacy/vtkDataWriter.cxx b/IO/Legacy/vtkDataWriter.cxx index a7efe3b83f1..9759b30d6bc 100644 --- a/IO/Legacy/vtkDataWriter.cxx +++ b/IO/Legacy/vtkDataWriter.cxx @@ -64,6 +64,7 @@ #include "vtkUnsignedLongArray.h" #include "vtkUnsignedShortArray.h" #include "vtkVariantArray.h" +#include "vtksys/FStream.hxx" #include <cstdio> #include <sstream> @@ -171,14 +172,14 @@ ostream* vtkDataWriter::OpenVTKFile() { if (this->FileType == VTK_ASCII) { - fptr = new ofstream(this->FileName, ios::out); + fptr = new vtksys::ofstream(this->FileName, ios::out); } else { #ifdef _WIN32 - fptr = new ofstream(this->FileName, ios::out | ios::binary); + fptr = new vtksys::ofstream(this->FileName, ios::out | ios::binary); #else - fptr = new ofstream(this->FileName, ios::out); + fptr = new vtksys::ofstream(this->FileName, ios::out); #endif } } diff --git a/IO/Legacy/vtkSimplePointsReader.cxx b/IO/Legacy/vtkSimplePointsReader.cxx index fa2286699b3..66cc4167e0e 100644 --- a/IO/Legacy/vtkSimplePointsReader.cxx +++ b/IO/Legacy/vtkSimplePointsReader.cxx @@ -19,6 +19,7 @@ #include "vtkPoints.h" #include "vtkPolyData.h" #include "vtkSmartPointer.h" +#include "vtksys/FStream.hxx" vtkStandardNewMacro(vtkSimplePointsReader); @@ -54,7 +55,7 @@ int vtkSimplePointsReader::RequestData( } // Open the input file. - ifstream fin(this->FileName); + vtksys::ifstream fin(this->FileName); if (!fin) { vtkErrorMacro("Error opening file " << this->FileName); diff --git a/IO/Legacy/vtkSimplePointsWriter.cxx b/IO/Legacy/vtkSimplePointsWriter.cxx index 28014328524..aa54795bab3 100644 --- a/IO/Legacy/vtkSimplePointsWriter.cxx +++ b/IO/Legacy/vtkSimplePointsWriter.cxx @@ -17,6 +17,7 @@ #include "vtkErrorCode.h" #include "vtkObjectFactory.h" #include "vtkPointSet.h" +#include "vtksys/FStream.hxx" #if !defined(_WIN32) || defined(__CYGWIN__) #include <unistd.h> /* unlink */ @@ -30,7 +31,7 @@ vtkStandardNewMacro(vtkSimplePointsWriter); vtkSimplePointsWriter::vtkSimplePointsWriter() { - std::ofstream fout; // only used to extract the default precision + vtksys::ofstream fout; // only used to extract the default precision this->DecimalPrecision = fout.precision(); } diff --git a/IO/MINC/vtkMNIObjectReader.cxx b/IO/MINC/vtkMNIObjectReader.cxx index 3b1da74bd6d..df9fa7361c5 100644 --- a/IO/MINC/vtkMNIObjectReader.cxx +++ b/IO/MINC/vtkMNIObjectReader.cxx @@ -69,6 +69,7 @@ POSSIBILITY OF SUCH DAMAGES. #include <string> #include <vector> +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> #ifndef VTK_BINARY @@ -139,7 +140,7 @@ int vtkMNIObjectReader::CanReadFile(const char* fname) // Try to read the first line of the file. int status = 0; - ifstream infile(fname); + vtksys::ifstream infile(fname); if (infile.good()) { @@ -728,7 +729,7 @@ int vtkMNIObjectReader::ReadFile(vtkPolyData* output) } // Make sure that the file is readable. - ifstream infile(this->FileName, ios::in); + vtksys::ifstream infile(this->FileName, ios::in); if (infile.fail()) { diff --git a/IO/MINC/vtkMNIObjectWriter.cxx b/IO/MINC/vtkMNIObjectWriter.cxx index 935075695bc..f10363d1155 100644 --- a/IO/MINC/vtkMNIObjectWriter.cxx +++ b/IO/MINC/vtkMNIObjectWriter.cxx @@ -65,6 +65,7 @@ POSSIBILITY OF SUCH DAMAGES. #include "vtkPolygon.h" #include "vtkProperty.h" #include "vtkUnsignedCharArray.h" +#include "vtksys/FStream.hxx" #include <cctype> #include <cmath> @@ -1023,14 +1024,14 @@ ostream* vtkMNIObjectWriter::OpenFile() if (this->FileType == VTK_ASCII) { - fptr = new ofstream(this->FileName, ios::out); + fptr = new vtksys::ofstream(this->FileName, ios::out); } else { #ifdef _WIN32 - fptr = new ofstream(this->FileName, ios::out | ios::binary); + fptr = new vtksys::ofstream(this->FileName, ios::out | ios::binary); #else - fptr = new ofstream(this->FileName, ios::out); + fptr = new vtksys::ofstream(this->FileName, ios::out); #endif } diff --git a/IO/MINC/vtkMNITagPointReader.cxx b/IO/MINC/vtkMNITagPointReader.cxx index 429e7bea82d..7cb1964b068 100644 --- a/IO/MINC/vtkMNITagPointReader.cxx +++ b/IO/MINC/vtkMNITagPointReader.cxx @@ -66,6 +66,7 @@ POSSIBILITY OF SUCH DAMAGES. #include <string> #include <vector> +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> //-------------------------------------------------------------------------- @@ -114,7 +115,7 @@ int vtkMNITagPointReader::CanReadFile(const char* fname) // Try to read the first line of the file. int status = 0; - ifstream infile(fname); + vtksys::ifstream infile(fname); if (infile.good()) { @@ -426,7 +427,7 @@ int vtkMNITagPointReader::ReadFile(vtkPolyData* output1, vtkPolyData* output2) } // Make sure that the file is readable. - ifstream infile(this->FileName); + vtksys::ifstream infile(this->FileName); std::string linetext; std::string::iterator pos = linetext.begin(); diff --git a/IO/MINC/vtkMNITagPointWriter.cxx b/IO/MINC/vtkMNITagPointWriter.cxx index 34540de2fee..d7ee8e6bba1 100644 --- a/IO/MINC/vtkMNITagPointWriter.cxx +++ b/IO/MINC/vtkMNITagPointWriter.cxx @@ -61,6 +61,7 @@ POSSIBILITY OF SUCH DAMAGES. #include "vtkPointSet.h" #include "vtkPoints.h" #include "vtkStringArray.h" +#include "vtksys/FStream.hxx" #include <cctype> #include <cmath> @@ -526,7 +527,7 @@ ostream* vtkMNITagPointWriter::OpenFile() vtkDebugMacro(<< "Opening file for writing..."); - fptr = new ofstream(this->FileName, ios::out); + fptr = new vtksys::ofstream(this->FileName, ios::out); if (fptr->fail()) { diff --git a/IO/MINC/vtkMNITransformReader.cxx b/IO/MINC/vtkMNITransformReader.cxx index 6c347a6a144..adb75929a51 100644 --- a/IO/MINC/vtkMNITransformReader.cxx +++ b/IO/MINC/vtkMNITransformReader.cxx @@ -67,6 +67,7 @@ POSSIBILITY OF SUCH DAMAGES. #include <string> #include <vector> +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> //-------------------------------------------------------------------------- @@ -126,7 +127,7 @@ int vtkMNITransformReader::CanReadFile(const char* fname) // Try to read the first line of the file. int status = 0; - ifstream infile(fname); + vtksys::ifstream infile(fname); if (infile.good()) { @@ -832,7 +833,7 @@ int vtkMNITransformReader::ReadFile() } // Make sure that the file is readable. - ifstream infile(this->FileName); + vtksys::ifstream infile(this->FileName); if (infile.fail()) { diff --git a/IO/MINC/vtkMNITransformWriter.cxx b/IO/MINC/vtkMNITransformWriter.cxx index b1567296117..b6c96387987 100644 --- a/IO/MINC/vtkMNITransformWriter.cxx +++ b/IO/MINC/vtkMNITransformWriter.cxx @@ -73,6 +73,7 @@ POSSIBILITY OF SUCH DAMAGES. #include <ctime> #include <stack> +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> //-------------------------------------------------------------------------- @@ -413,7 +414,7 @@ int vtkMNITransformWriter::WriteFile() } // Open the file. - ofstream outfile(this->FileName, ios::out); + vtksys::ofstream outfile(this->FileName, ios::out); if (outfile.fail()) { diff --git a/IO/PLY/Testing/Cxx/TestPLYWriterString.cxx b/IO/PLY/Testing/Cxx/TestPLYWriterString.cxx index 13fa1ab3991..5e2b2bf47b9 100644 --- a/IO/PLY/Testing/Cxx/TestPLYWriterString.cxx +++ b/IO/PLY/Testing/Cxx/TestPLYWriterString.cxx @@ -23,6 +23,7 @@ #include "vtkPointData.h" #include "vtkPolyData.h" #include "vtkTestUtilities.h" +#include "vtksys/FStream.hxx" #include <cmath> #include <fstream> @@ -37,9 +38,9 @@ int TestPLYWriterString(int argc, char* argv[]) std::string filename = tempFileName; delete[] tempFileName; - std::ifstream ifs; + vtksys::ifstream ifs; - ifs.open(filename, std::ifstream::in | std::ifstream::binary); + ifs.open(filename.c_str(), std::ios::in | std::ios::binary); if (!ifs.is_open()) { std::cout << "Can not read the input file." << std::endl; diff --git a/IO/PLY/vtkPLY.cxx b/IO/PLY/vtkPLY.cxx index 4501280b30e..aff3607f21f 100644 --- a/IO/PLY/vtkPLY.cxx +++ b/IO/PLY/vtkPLY.cxx @@ -50,6 +50,7 @@ WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. #include "vtkByteSwap.h" #include "vtkHeap.h" #include "vtkMath.h" +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> #include <cassert> @@ -171,7 +172,7 @@ PlyFile* vtkPLY::ply_open_for_writing( { PlyFile* plyfile; char* name; - std::ofstream* ofs = nullptr; + vtksys::ofstream* ofs = nullptr; // memory leaks plyInitialize(); @@ -184,7 +185,7 @@ PlyFile* vtkPLY::ply_open_for_writing( strcat(name, ".ply"); /* open the file for writing */ - ofs = new std::ofstream; + ofs = new vtksys::ofstream; ofs->open(name, std::istream::out | std::istream::binary); free(name); // wjs remove memory leak// @@ -815,16 +816,16 @@ Exit: PlyFile* vtkPLY::ply_open_for_reading(const char* filename, int* nelems, char*** elem_names) { - std::ifstream* ifs; + vtksys::ifstream* ifs; PlyFile* plyfile; // memory leaks plyInitialize(); /* open the file for reading */ - ifs = new std::ifstream; + ifs = new vtksys::ifstream; - ifs->open(filename, std::ifstream::in | std::ifstream::binary); + ifs->open(filename, std::ios::in | std::ios::binary); if (!ifs->is_open()) { delete ifs; @@ -1375,7 +1376,7 @@ void vtkPLY::ply_close(PlyFile* plyfile) /* free up memory associated with the PLY file */ if (plyfile->is) { - std::ifstream* ifs = dynamic_cast<std::ifstream*>(plyfile->is); + vtksys::ifstream* ifs = dynamic_cast<vtksys::ifstream*>(plyfile->is); if (ifs) { ifs->close(); @@ -1384,7 +1385,7 @@ void vtkPLY::ply_close(PlyFile* plyfile) } if (plyfile->os) { - std::ofstream* ofs = dynamic_cast<std::ofstream*>(plyfile->os); + vtksys::ofstream* ofs = dynamic_cast<vtksys::ofstream*>(plyfile->os); if (ofs) { ofs->close(); diff --git a/IO/Parallel/vtkPDataSetReader.cxx b/IO/Parallel/vtkPDataSetReader.cxx index b32bfdc7fa4..ab4595e84de 100644 --- a/IO/Parallel/vtkPDataSetReader.cxx +++ b/IO/Parallel/vtkPDataSetReader.cxx @@ -33,6 +33,7 @@ #include "vtkStructuredPoints.h" #include "vtkStructuredPointsReader.h" #include "vtkUnstructuredGrid.h" +#include "vtksys/Encoding.hxx" vtkStandardNewMacro(vtkPDataSetReader); @@ -196,7 +197,7 @@ int vtkPDataSetReader::RequestDataObject( // Returns 5 for end block. // ======= // The statics should be instance variables ... -int vtkPDataSetReader::ReadXML(ifstream* file, char** retBlock, char** retParam, char** retVal) +int vtkPDataSetReader::ReadXML(istream* file, char** retBlock, char** retParam, char** retVal) { static char str[1024]; static char* ptr = nullptr; @@ -430,7 +431,7 @@ int vtkPDataSetReader::CanReadFile(const char* filename) //---------------------------------------------------------------------------- void vtkPDataSetReader::ReadPVTKFileInformation( - ifstream* file, vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) + istream* file, vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) { char* block; char* param; @@ -657,7 +658,11 @@ ifstream* vtkPDataSetReader::OpenFile(const char* filename) } // Open the new file +#ifdef _WIN32 + file = new ifstream(vtksys::Encoding::ToWindowsExtendedPath(filename), ios::in); +#else file = new ifstream(filename, ios::in); +#endif if (!file || file->fail()) { diff --git a/IO/Parallel/vtkPDataSetReader.h b/IO/Parallel/vtkPDataSetReader.h index 226a3870241..2e290ba97ba 100644 --- a/IO/Parallel/vtkPDataSetReader.h +++ b/IO/Parallel/vtkPDataSetReader.h @@ -62,7 +62,7 @@ protected: int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) override; - void ReadPVTKFileInformation(ifstream* fp, vtkInformation* request, + void ReadPVTKFileInformation(istream* fp, vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector); void ReadVTKFileInformation(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector); @@ -82,7 +82,7 @@ protected: ifstream* OpenFile(const char*); - int ReadXML(ifstream* file, char** block, char** param, char** value); + int ReadXML(istream* file, char** block, char** param, char** value); int VTKFileFlag; int StructuredFlag; char* FileName; diff --git a/IO/Parallel/vtkPDataSetWriter.cxx b/IO/Parallel/vtkPDataSetWriter.cxx index f7d02f200c9..c1179694557 100644 --- a/IO/Parallel/vtkPDataSetWriter.cxx +++ b/IO/Parallel/vtkPDataSetWriter.cxx @@ -23,6 +23,7 @@ #include "vtkRectilinearGrid.h" #include "vtkStreamingDemandDrivenPipeline.h" #include "vtkStructuredGrid.h" +#include "vtksys/FStream.hxx" vtkStandardNewMacro(vtkPDataSetWriter); @@ -512,7 +513,7 @@ ostream* vtkPDataSetWriter::OpenFile() { ostream* fptr; - fptr = new ofstream(this->FileName, ios::out); + fptr = new vtksys::ofstream(this->FileName, ios::out); if (fptr->fail()) { diff --git a/IO/Parallel/vtkPImageWriter.cxx b/IO/Parallel/vtkPImageWriter.cxx index e7c607a58ca..bed5b3052e9 100644 --- a/IO/Parallel/vtkPImageWriter.cxx +++ b/IO/Parallel/vtkPImageWriter.cxx @@ -20,12 +20,13 @@ #include "vtkObjectFactory.h" #include "vtkPipelineSize.h" #include "vtkStreamingDemandDrivenPipeline.h" +#include "vtksys/FStream.hxx" #define vtkPIWCloseFile \ if (file && fileOpenedHere) \ { \ this->WriteFileTrailer(file, cache); \ - ofstream* ofile = dynamic_cast<ofstream*>(file); \ + vtksys::ofstream* ofile = dynamic_cast<vtksys::ofstream*>(file); \ if (ofile) \ { \ ofile->close(); \ @@ -102,9 +103,9 @@ void vtkPImageWriter::RecursiveWrite( } // Open the file #ifdef _WIN32 - file = new ofstream(this->InternalFileName, ios::out | ios::binary); + file = new vtksys::ofstream(this->InternalFileName, ios::out | ios::binary); #else - file = new ofstream(this->InternalFileName, ios::out); + file = new vtksys::ofstream(this->InternalFileName, ios::out); #endif fileOpenedHere = 1; if (file->fail()) diff --git a/IO/Parallel/vtkPlot3DMetaReader.cxx b/IO/Parallel/vtkPlot3DMetaReader.cxx index ccbf727684b..d650bbd7655 100644 --- a/IO/Parallel/vtkPlot3DMetaReader.cxx +++ b/IO/Parallel/vtkPlot3DMetaReader.cxx @@ -22,6 +22,7 @@ #include "vtkObjectFactory.h" #include "vtkStreamingDemandDrivenPipeline.h" +#include "vtksys/FStream.hxx" #include <vtksys/SystemTools.hxx> #include <map> @@ -344,7 +345,7 @@ int vtkPlot3DMetaReader::RequestInformation(vtkInformation* vtkNotUsed(request), return 0; } - ifstream file(this->FileName); + vtksys::ifstream file(this->FileName); Json::CharReaderBuilder rbuilder; rbuilder["collectComments"] = true; diff --git a/IO/ParallelXML/Testing/Cxx/TestParallelUnstructuredGridIO.cxx b/IO/ParallelXML/Testing/Cxx/TestParallelUnstructuredGridIO.cxx index 85187412214..3f84a204b97 100644 --- a/IO/ParallelXML/Testing/Cxx/TestParallelUnstructuredGridIO.cxx +++ b/IO/ParallelXML/Testing/Cxx/TestParallelUnstructuredGridIO.cxx @@ -1,6 +1,7 @@ #include "vtkNew.h" #include <string> +#include "vtksys/FStream.hxx" #include <vtkCell.h> #include <vtkIdList.h> #include <vtkMultiProcessController.h> @@ -200,7 +201,7 @@ int TestParallelUnstructuredGridIO(int argc, char* argv[]) w->SetDataModeToAscii(); w->Update(); delete[] tempDir; - ifstream f(fn.c_str()); + vtksys::ifstream f(fn.c_str()); if (!f.good()) { std::cerr << "File " << fn << " does not exist." << std::endl; diff --git a/IO/SQL/Testing/Cxx/TestSQLiteTableReadWrite.cxx b/IO/SQL/Testing/Cxx/TestSQLiteTableReadWrite.cxx index 3461d359133..d305a0018c4 100644 --- a/IO/SQL/Testing/Cxx/TestSQLiteTableReadWrite.cxx +++ b/IO/SQL/Testing/Cxx/TestSQLiteTableReadWrite.cxx @@ -26,6 +26,7 @@ #include "vtkSQLiteToTableReader.h" #include "vtkTableToSQLiteWriter.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" void PrintFile(const char* name, std::ostream& os); @@ -121,7 +122,7 @@ void PrintFile(const char* name, std::ostream& os) os << " has " << fs.st_size << " bytes"; } - std::ifstream fin(name); + vtksys::ifstream fin(name); if (fin) { os << ":\n" << div << "\n"; @@ -138,13 +139,13 @@ void PrintFile(const char* name, std::ostream& os) bool CompareAsciiFiles(const char* file1, const char* file2) { // Open the two files for read - std::ifstream fin1(file1); + vtksys::ifstream fin1(file1); if (!fin1) { std::cerr << file2 << " cannot be opened for read.\n"; return false; } - std::ifstream fin2(file2); + vtksys::ifstream fin2(file2); if (!fin2) { std::cerr << file2 << " cannot be opened for read.\n"; diff --git a/IO/SQL/vtkSQLiteDatabase.cxx b/IO/SQL/vtkSQLiteDatabase.cxx index 6572664d9c7..f354a9c1733 100644 --- a/IO/SQL/vtkSQLiteDatabase.cxx +++ b/IO/SQL/vtkSQLiteDatabase.cxx @@ -28,6 +28,7 @@ #include <fstream> #include <sstream> +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> #include "vtk_sqlite.h" @@ -299,7 +300,7 @@ bool vtkSQLiteDatabase::Open(const char* password, int mode) if (mode == CREATE_OR_CLEAR && exists) { // Here we need to clear the file if it exists by opening it. - std::ofstream os; + vtksys::ofstream os; os.open(this->DatabaseFileName); if (!os.is_open()) { diff --git a/IO/TecplotTable/vtkTecplotTableReader.cxx b/IO/TecplotTable/vtkTecplotTableReader.cxx index de6e0e21542..0c24abb4fdd 100644 --- a/IO/TecplotTable/vtkTecplotTableReader.cxx +++ b/IO/TecplotTable/vtkTecplotTableReader.cxx @@ -30,6 +30,7 @@ #include "vtkTextCodec.h" #include "vtkTextCodecFactory.h" +#include "vtksys/FStream.hxx" #include <algorithm> #include <iostream> @@ -405,7 +406,7 @@ int vtkTecplotTableReader::RequestData( } istream* input_stream_pt = nullptr; - ifstream file_stream; + vtksys::ifstream file_stream; // If the filename hasn't been specified, we're done ... if (!this->FileName) diff --git a/IO/XML/Testing/Cxx/TestReadDuplicateDataArrayNames.cxx b/IO/XML/Testing/Cxx/TestReadDuplicateDataArrayNames.cxx index 5a7420d59cd..307ee172b27 100644 --- a/IO/XML/Testing/Cxx/TestReadDuplicateDataArrayNames.cxx +++ b/IO/XML/Testing/Cxx/TestReadDuplicateDataArrayNames.cxx @@ -13,6 +13,7 @@ =========================================================================*/ +#include "vtksys/FStream.hxx" #include <vtkPointData.h> #include <vtkSmartPointer.h> #include <vtkTestUtilities.h> @@ -101,7 +102,7 @@ void generateDataSetWithDuplicateArrayNames(const std::string& filename) "</UnstructuredGrid>\n" "</VTKFile>"; - ofstream myfile; + vtksys::ofstream myfile; myfile.open(filename.c_str()); myfile << dataSet; myfile.close(); diff --git a/IO/XML/Testing/Cxx/TestXMLMappedUnstructuredGridIO.cxx b/IO/XML/Testing/Cxx/TestXMLMappedUnstructuredGridIO.cxx index 3d0075591dd..9e05b0861e6 100644 --- a/IO/XML/Testing/Cxx/TestXMLMappedUnstructuredGridIO.cxx +++ b/IO/XML/Testing/Cxx/TestXMLMappedUnstructuredGridIO.cxx @@ -29,6 +29,7 @@ #include "vtkUnstructuredGrid.h" #include "vtkXMLUnstructuredGridReader.h" #include "vtkXMLUnstructuredGridWriter.h" +#include "vtksys/FStream.hxx" #include <algorithm> #include <fstream> @@ -309,8 +310,8 @@ using namespace std; bool compareFiles(const string& p1, const string& p2) { - ifstream f1(p1, ifstream::binary | ifstream::ate); - ifstream f2(p2, ifstream::binary | ifstream::ate); + vtksys::ifstream f1(p1.c_str(), ifstream::binary | ifstream::ate); + vtksys::ifstream f2(p2.c_str(), ifstream::binary | ifstream::ate); if (f1.fail() || f2.fail()) { @@ -323,8 +324,8 @@ bool compareFiles(const string& p1, const string& p2) } // seek back to beginning and use equal to compare contents - f1.seekg(0, ifstream::beg); - f2.seekg(0, ifstream::beg); + f1.seekg(0, vtksys::ifstream::beg); + f2.seekg(0, vtksys::ifstream::beg); return equal(istreambuf_iterator<char>(f1.rdbuf()), istreambuf_iterator<char>(), istreambuf_iterator<char>(f2.rdbuf())); } diff --git a/IO/XML/vtkXMLFileReadTester.cxx b/IO/XML/vtkXMLFileReadTester.cxx index 8e52ec46198..34c7fb4a7d2 100644 --- a/IO/XML/vtkXMLFileReadTester.cxx +++ b/IO/XML/vtkXMLFileReadTester.cxx @@ -14,6 +14,7 @@ =========================================================================*/ #include "vtkXMLFileReadTester.h" #include "vtkObjectFactory.h" +#include "vtksys/FStream.hxx" vtkStandardNewMacro(vtkXMLFileReadTester); @@ -47,7 +48,7 @@ int vtkXMLFileReadTester::TestReadFile() return 0; } - ifstream inFile(this->FileName); + vtksys::ifstream inFile(this->FileName); if (!inFile) { return 0; diff --git a/IO/XML/vtkXMLReader.cxx b/IO/XML/vtkXMLReader.cxx index 6ea02a574db..eb56ea86608 100644 --- a/IO/XML/vtkXMLReader.cxx +++ b/IO/XML/vtkXMLReader.cxx @@ -44,6 +44,7 @@ #include "vtkXMLReaderVersion.h" #include "vtkZLibDataCompressor.h" +#include "vtksys/Encoding.hxx" #include <vtksys/SystemTools.hxx> #include <algorithm> @@ -294,7 +295,8 @@ int vtkXMLReader::OpenVTKFile() } #ifdef _WIN32 - this->FileStream = new ifstream(this->FileName, ios::binary | ios::in); + std::wstring wfilename = vtksys::Encoding::ToWindowsExtendedPath(this->FileName); + this->FileStream = new ifstream(wfilename, ios::binary | ios::in); #else this->FileStream = new ifstream(this->FileName, ios::in); #endif diff --git a/IO/XML/vtkXMLWriter.cxx b/IO/XML/vtkXMLWriter.cxx index da9bf95259f..9992e95e034 100644 --- a/IO/XML/vtkXMLWriter.cxx +++ b/IO/XML/vtkXMLWriter.cxx @@ -60,6 +60,7 @@ #include "vtkQuadratureSchemeDefinition.h" #include "vtkXMLDataElement.h" #include "vtkXMLReaderVersion.h" +#include "vtksys/Encoding.hxx" #include <memory> #include <cassert> @@ -904,7 +905,8 @@ int vtkXMLWriter::OpenFile() // Try to open the output file for writing. #ifdef _WIN32 - this->OutFile = new ofstream(this->FileName, ios::out | ios::binary); + this->OutFile = + new ofstream(vtksys::Encoding::ToWindowsExtendedPath(this->FileName), ios::out | ios::binary); #else this->OutFile = new ofstream(this->FileName, ios::out); #endif diff --git a/IO/XMLParser/vtkXMLParser.cxx b/IO/XMLParser/vtkXMLParser.cxx index bf1abbe457f..090c64bfe5c 100644 --- a/IO/XMLParser/vtkXMLParser.cxx +++ b/IO/XMLParser/vtkXMLParser.cxx @@ -16,6 +16,7 @@ #include "vtkObjectFactory.h" #include "vtk_expat.h" +#include "vtksys/FStream.hxx" #include <vtksys/SystemTools.hxx> #include <cctype> @@ -119,7 +120,7 @@ int vtkXMLParser::Parse(const char* inputString, unsigned int length) int vtkXMLParser::Parse() { // Select source of XML - ifstream ifs; + vtksys::ifstream ifs; if (!this->InputString && !this->Stream && this->FileName) { // If it is file, open it and set the appropriate stream diff --git a/IO/XMLParser/vtkXMLUtilities.cxx b/IO/XMLParser/vtkXMLUtilities.cxx index d64f99ef9f3..f306fc24e52 100644 --- a/IO/XMLParser/vtkXMLUtilities.cxx +++ b/IO/XMLParser/vtkXMLUtilities.cxx @@ -17,6 +17,7 @@ #include "vtkObjectFactory.h" #include "vtkXMLDataElement.h" #include "vtkXMLDataParser.h" +#include "vtksys/FStream.hxx" #include <sstream> @@ -362,7 +363,7 @@ int vtkXMLUtilities::WriteElementToFile( return 0; } - ofstream os(filename, ios::out); + vtksys::ofstream os(filename, ios::out); vtkXMLUtilities::FlattenElement(elem, os, indent); os.flush(); @@ -419,7 +420,7 @@ vtkXMLDataElement* vtkXMLUtilities::ReadElementFromFile(const char* filename, in return nullptr; } - ifstream is(filename); + vtksys::ifstream is(filename); return vtkXMLUtilities::ReadElementFromStream(is, encoding); } diff --git a/IO/Xdmf2/vtkXdmfReader.cxx b/IO/Xdmf2/vtkXdmfReader.cxx index 2fdfa1780cf..034fc85e6a4 100644 --- a/IO/Xdmf2/vtkXdmfReader.cxx +++ b/IO/Xdmf2/vtkXdmfReader.cxx @@ -44,7 +44,7 @@ public: return 0; } - ifstream inFile(this->FileName); + vtksys::ifstream inFile(this->FileName); if (!inFile) { return 0; diff --git a/Infovis/Core/vtkWordCloud.cxx b/Infovis/Core/vtkWordCloud.cxx index 3dfe9c3fb62..068e1bd85ce 100644 --- a/Infovis/Core/vtkWordCloud.cxx +++ b/Infovis/Core/vtkWordCloud.cxx @@ -42,6 +42,7 @@ #include "vtkImageReader2Factory.h" #include "vtkImageResize.h" +#include "vtksys/FStream.hxx" #include "vtksys/SystemTools.hxx" #ifdef HAS_STD_REGEX #include <regex> @@ -193,7 +194,7 @@ int vtkWordCloud::RequestData(vtkInformation* vtkNotUsed(request), return 0; } // Open the text file - std::ifstream t(this->FileName); + vtksys::ifstream t(this->FileName.c_str()); std::stringstream buffer; buffer << t.rdbuf(); std::string s = buffer.str(); @@ -762,7 +763,7 @@ void ShowColorSeriesNames(ostream& os) void CreateStopListFromFile(std::string fileName, vtkWordCloud::StopWordsContainer& stopList) { - std::ifstream t(fileName); + vtksys::ifstream t(fileName.c_str()); std::stringstream buffer; buffer << t.rdbuf(); std::string s = buffer.str(); diff --git a/Interaction/Widgets/Testing/Cxx/TestPickingManagerSeedWidget.cxx b/Interaction/Widgets/Testing/Cxx/TestPickingManagerSeedWidget.cxx index 68fe85ba2e2..54d944fc4ac 100644 --- a/Interaction/Widgets/Testing/Cxx/TestPickingManagerSeedWidget.cxx +++ b/Interaction/Widgets/Testing/Cxx/TestPickingManagerSeedWidget.cxx @@ -67,6 +67,7 @@ #include "vtkSphereHandleRepresentation.h" #include "vtkStdString.h" #include "vtkTimerLog.h" +#include "vtksys/FStream.hxx" // STL includes #include <fstream> @@ -445,7 +446,7 @@ public: this->logTime->StartTimer(); } - std::ofstream performanceReport; + vtksys::ofstream performanceReport; vtkTimerLog* logTime; private: diff --git a/Parallel/Core/vtkSocketCommunicator.cxx b/Parallel/Core/vtkSocketCommunicator.cxx index 6e76c9d304f..6943f40e2af 100644 --- a/Parallel/Core/vtkSocketCommunicator.cxx +++ b/Parallel/Core/vtkSocketCommunicator.cxx @@ -21,6 +21,7 @@ #include "vtkSocketController.h" #include "vtkStdString.h" #include "vtkTypeTraits.h" +#include "vtksys/Encoding.hxx" #include <cassert> #include <algorithm> @@ -208,7 +209,13 @@ int vtkSocketCommunicator::LogToFile(const char* name, int append) // Log to given file, if any. if (name && name[0]) { +#ifdef _WIN32 + std::wstring wname = vtksys::Encoding::ToWindowsExtendedPath(name); + this->LogFile = new ofstream(wname, (ios::out | (append ? ios::ate : ios::trunc))); +#else this->LogFile = new ofstream(name, (ios::out | (append ? ios::ate : ios::trunc))); +#endif + if (!this->LogFile) { return 0; diff --git a/Rendering/Core/vtkInteractorEventRecorder.cxx b/Rendering/Core/vtkInteractorEventRecorder.cxx index 4792dac7852..b35267cc05c 100644 --- a/Rendering/Core/vtkInteractorEventRecorder.cxx +++ b/Rendering/Core/vtkInteractorEventRecorder.cxx @@ -21,6 +21,7 @@ #include <locale> #include <sstream> #include <string> +#include <vtksys/FStream.hxx> #include <vtksys/SystemTools.hxx> vtkStandardNewMacro(vtkInteractorEventRecorder); @@ -131,7 +132,7 @@ void vtkInteractorEventRecorder::Record() { if (!this->OutputStream) // need to open file { - this->OutputStream = new ofstream(this->FileName, ios::out); + this->OutputStream = new vtksys::ofstream(this->FileName, ios::out); if (this->OutputStream->fail()) { vtkErrorMacro(<< "Unable to open file: " << this->FileName); @@ -184,7 +185,7 @@ void vtkInteractorEventRecorder::Play() { if (!this->InputStream) // need to open file { - this->InputStream = new ifstream(this->FileName, ios::in); + this->InputStream = new vtksys::ifstream(this->FileName, ios::in); if (this->InputStream->fail()) { vtkErrorMacro(<< "Unable to open file: " << this->FileName); diff --git a/Rendering/Label/vtkDynamic2DLabelMapper.cxx b/Rendering/Label/vtkDynamic2DLabelMapper.cxx index 8934bebcbfb..7189d8c1e76 100644 --- a/Rendering/Label/vtkDynamic2DLabelMapper.cxx +++ b/Rendering/Label/vtkDynamic2DLabelMapper.cxx @@ -45,9 +45,9 @@ #include "vtkTypeTraits.h" #include "vtkUnicodeStringArray.h" #include "vtkViewport.h" +#include "vtksys/FStream.hxx" #include <fstream> -using std::ofstream; vtkStandardNewMacro(vtkDynamic2DLabelMapper); diff --git a/Rendering/OpenGL2/vtkShaderProgram.cxx b/Rendering/OpenGL2/vtkShaderProgram.cxx index a1ec5e43847..56d5c928827 100644 --- a/Rendering/OpenGL2/vtkShaderProgram.cxx +++ b/Rendering/OpenGL2/vtkShaderProgram.cxx @@ -22,6 +22,7 @@ #include "vtkTransformFeedback.h" #include "vtkTypeTraits.h" #include "vtk_glew.h" +#include "vtksys/FStream.hxx" #include <cassert> #include <iostream> @@ -396,14 +397,14 @@ bool vtkShaderProgram::Bind() fname += exts[cc]; if (vtksys::SystemTools::FileExists(fname)) { - std::ifstream ifp(fname.c_str()); + vtksys::ifstream ifp(fname.c_str()); assert(ifp); std::string source((std::istreambuf_iterator<char>(ifp)), std::istreambuf_iterator<char>()); shaders[cc]->SetSource(source); } else { - std::ofstream ofp(fname.c_str()); + vtksys::ofstream ofp(fname.c_str()); ofp << shaders[cc]->GetSource().c_str(); } } diff --git a/Rendering/OpenVR/vtkOpenVROverlay.cxx b/Rendering/OpenVR/vtkOpenVROverlay.cxx index 367ad9d51c7..0192869f61e 100644 --- a/Rendering/OpenVR/vtkOpenVROverlay.cxx +++ b/Rendering/OpenVR/vtkOpenVROverlay.cxx @@ -108,7 +108,7 @@ void vtkOpenVROverlay::WriteCameraPoses() { std::string fname = this->GetSessionName(); fname += "VTKOpenVRCameraPoses.vovrcp"; - ofstream os(fname, ios::out); + vtksys::ofstream os(fname, ios::out); this->WriteCameraPoses(os); os.flush(); @@ -129,7 +129,7 @@ void vtkOpenVROverlay::ReadCameraPoses() return; } - ifstream is(fname); + vtksys::ifstream is(fname); this->ReadCameraPoses(is); } diff --git a/Rendering/Parallel/vtkCompositeZPass.cxx b/Rendering/Parallel/vtkCompositeZPass.cxx index fb7441f50d6..a684305f54c 100644 --- a/Rendering/Parallel/vtkCompositeZPass.cxx +++ b/Rendering/Parallel/vtkCompositeZPass.cxx @@ -231,7 +231,7 @@ void vtkCompositeZPass::Render(const vtkRenderState* s) ost00.precision(5); ost00 << "OpenGLState_" << pthread_self() << "_" << vtkTimerLog::GetUniversalTime() << "_root00.txt"; - ofstream outfile00(ost00.str().c_str()); + vtksys::ofstream outfile00(ost00.str().c_str()); state->PrintSelf(outfile00, indent); outfile00.close(); @@ -243,7 +243,7 @@ void vtkCompositeZPass::Render(const vtkRenderState* s) ost01.precision(5); ost01 << "OpenGLState_" << pthread_self() << "_" << vtkTimerLog::GetUniversalTime() << "_root01.txt"; - ofstream outfile01(ost01.str().c_str()); + vtksys::ofstream outfile01(ost01.str().c_str()); state->PrintSelf(outfile01, indent); outfile01.close(); @@ -351,7 +351,7 @@ void vtkCompositeZPass::Render(const vtkRenderState* s) ost02 << "OpenGLState_" << pthread_self() << "_" << vtkTimerLog::GetUniversalTime() << "_root02_proc_" << proc << "_" << ".txt"; - ofstream outfile02(ost02.str().c_str()); + vtksys::ofstream outfile02(ost02.str().c_str()); state->PrintSelf(outfile02, indent); outfile02.close(); #endif @@ -366,7 +366,7 @@ void vtkCompositeZPass::Render(const vtkRenderState* s) ost03 << "OpenGLState_" << pthread_self() << "_" << vtkTimerLog::GetUniversalTime() << "_root03_proc_" << proc << "_" << ".txt"; - ofstream outfile03(ost03.str().c_str()); + vtksys::ofstream outfile03(ost03.str().c_str()); state->PrintSelf(outfile03, indent); outfile03.close(); @@ -406,7 +406,7 @@ void vtkCompositeZPass::Render(const vtkRenderState* s) ost04.precision(5); ost04 << "OpenGLState_" << pthread_self() << "_" << vtkTimerLog::GetUniversalTime() << "_root_proc_" << proc << "_before_copyframe.txt"; - ofstream outfile04(ost04.str().c_str()); + vtksys::ofstream outfile04(ost04.str().c_str()); state->PrintSelf(outfile04, indent); outfile04.close(); #endif @@ -421,7 +421,7 @@ void vtkCompositeZPass::Render(const vtkRenderState* s) ost05.precision(5); ost05 << "OpenGLState_" << pthread_self() << "_" << vtkTimerLog::GetUniversalTime() << "_root_proc_" << proc << "_after_copyframe.txt"; - ofstream outfile05(ost05.str().c_str()); + vtksys::ofstream outfile05(ost05.str().c_str()); state->PrintSelf(outfile05, indent); outfile05.close(); #endif @@ -435,7 +435,7 @@ void vtkCompositeZPass::Render(const vtkRenderState* s) ost06.precision(5); ost06 << "OpenGLState_" << pthread_self() << "_" << vtkTimerLog::GetUniversalTime() << "_root_proc_" << proc << "_before_popattrib.txt"; - ofstream outfile06(ost06.str().c_str()); + vtksys::ofstream outfile06(ost06.str().c_str()); state->PrintSelf(outfile06, indent); outfile06.close(); #endif @@ -447,7 +447,7 @@ void vtkCompositeZPass::Render(const vtkRenderState* s) ost07.precision(5); ost07 << "OpenGLState_" << pthread_self() << "_" << vtkTimerLog::GetUniversalTime() << "_root_proc_" << proc << "_after_popattrib.txt"; - ofstream outfile07(ost07.str().c_str()); + vtksys::ofstream outfile07(ost07.str().c_str()); state->PrintSelf(outfile07, indent); outfile07.close(); #endif diff --git a/Rendering/ParallelLIC/vtkParallelTimer.cxx b/Rendering/ParallelLIC/vtkParallelTimer.cxx index bc7d0b3229d..73ec913344a 100644 --- a/Rendering/ParallelLIC/vtkParallelTimer.cxx +++ b/Rendering/ParallelLIC/vtkParallelTimer.cxx @@ -60,6 +60,7 @@ static int gettimeofday(struct timeval* tv, void*) #include <fstream> using std::ios_base; using std::ofstream; +using vtksys::ofstream; /* For singleton pattern @@ -621,7 +622,7 @@ int vtkParallelTimer::Write() ostringstream oss; *this->Log >> oss; - ofstream f(this->FileName, ios_base::out | ios_base::app); + vtksys::ofstream f(this->FileName, ios_base::out | ios_base::app); if (!f.good()) { vtkErrorMacro(<< "Failed to open " << this->FileName << " for writing."); diff --git a/Rendering/RayTracing/vtkOSPRayMaterialLibrary.cxx b/Rendering/RayTracing/vtkOSPRayMaterialLibrary.cxx index 520ab024f47..fcfa67b5514 100644 --- a/Rendering/RayTracing/vtkOSPRayMaterialLibrary.cxx +++ b/Rendering/RayTracing/vtkOSPRayMaterialLibrary.cxx @@ -235,7 +235,7 @@ bool vtkOSPRayMaterialLibrary::InternalParse(const char* filename, bool fromfile std::istream* doc; if (fromfile) { - doc = new std::ifstream(filename, std::ifstream::binary); + doc = new vtksys::ifstream(filename, std::ios::binary); } else { diff --git a/Rendering/Volume/Testing/Cxx/TestGPURayCastClippingUserTransform.cxx b/Rendering/Volume/Testing/Cxx/TestGPURayCastClippingUserTransform.cxx index 9768faf2f93..13a737a1215 100644 --- a/Rendering/Volume/Testing/Cxx/TestGPURayCastClippingUserTransform.cxx +++ b/Rendering/Volume/Testing/Cxx/TestGPURayCastClippingUserTransform.cxx @@ -39,6 +39,7 @@ using namespace std; #include "vtkUnsignedShortArray.h" #include "vtkVolume.h" #include "vtkVolumeProperty.h" +#include "vtksys/FStream.hxx" #include "vtkRegressionTestImage.h" #include "vtkTestUtilities.h" @@ -169,7 +170,7 @@ int TestGPURayCastClippingUserTransform(int argc, char* argv[]) char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/MagnitudeImage_256x256x148"); - ifstream file(fname, ios::in | ios::binary | ios::ate); + vtksys::ifstream file(fname, ios::in | ios::binary | ios::ate); if (file.is_open()) { size = file.tellg(); diff --git a/Utilities/Benchmarks/vtkRenderTimings.cxx b/Utilities/Benchmarks/vtkRenderTimings.cxx index bf4c97f4aa7..4076d08f604 100644 --- a/Utilities/Benchmarks/vtkRenderTimings.cxx +++ b/Utilities/Benchmarks/vtkRenderTimings.cxx @@ -301,7 +301,7 @@ void vtkRenderTimings::ReportResults() } // then the detailed to a csv file - ofstream rfile; + vtksys::ofstream rfile; rfile.open(this->DetailedResultsFileName.c_str()); for (tsItr = this->TestSequences.begin(); tsItr != this->TestSequences.end(); ++tsItr) { diff --git a/Web/WebGLExporter/vtkPVWebGLExporter.cxx b/Web/WebGLExporter/vtkPVWebGLExporter.cxx index 65c84247596..7be8222a3d3 100644 --- a/Web/WebGLExporter/vtkPVWebGLExporter.cxx +++ b/Web/WebGLExporter/vtkPVWebGLExporter.cxx @@ -28,6 +28,7 @@ #include <fstream> #include <sstream> #include <string> +#include <vtksys/FStream.hxx> vtkStandardNewMacro(vtkPVWebGLExporter); // --------------------------------------------------------------------------- @@ -92,7 +93,7 @@ void vtkPVWebGLExporter::WriteData() // Manage binary content std::stringstream filePath; filePath << baseFileName.c_str() << "_" << obj->GetMD5().c_str() << "_" << part; - std::fstream binaryFile; + vtksys::ofstream binaryFile; binaryFile.open(filePath.str().c_str(), std::ios_base::out | std::ios_base::binary); binaryFile.write((const char*)obj->GetBinaryData(part), obj->GetBinarySize(part)); binaryFile.close(); @@ -101,7 +102,7 @@ void vtkPVWebGLExporter::WriteData() std::stringstream filePathBase64; filePathBase64 << baseFileName.c_str() << "_" << obj->GetMD5().c_str() << "_" << part << ".base64"; - std::fstream base64File; + vtksys::ofstream base64File; unsigned char* output = new unsigned char[obj->GetBinarySize(part) * 2]; int size = base64->Encode(obj->GetBinaryData(part), obj->GetBinarySize(part), output, false); diff --git a/Web/WebGLExporter/vtkWebGLExporter.cxx b/Web/WebGLExporter/vtkWebGLExporter.cxx index e20e73ee51d..b445f7144d5 100644 --- a/Web/WebGLExporter/vtkWebGLExporter.cxx +++ b/Web/WebGLExporter/vtkWebGLExporter.cxx @@ -775,7 +775,7 @@ void vtkWebGLExporter::exportStaticScene( resultHTML += "</script></html>"; - ofstream file; + vtksys::ofstream file; file.open(path.c_str()); file << resultHTML; file.close(); -- GitLab