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

Method InflateNext

IO/Geometry/vtkOpenFOAMReader.cxx:2907–2991  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2905}
2906
2907bool vtkFoamFile::InflateNext(unsigned char* buf, size_t requestSize, vtkTypeInt64* readSize)
2908{
2909#if VTK_OPENFOAM_TIME_PROFILING
2910 auto start = std::chrono::high_resolution_clock::now();
2911#endif
2912 if (readSize)
2913 {
2914 *readSize = -1; // Set to an error state for early returns
2915 }
2916 size_t size;
2917 if (this->Superclass::IsCompressed)
2918 {
2919 if (this->Superclass::ZStatus != Z_OK)
2920 {
2921 return false;
2922 }
2923 this->Superclass::Z.next_out = buf;
2924 this->Superclass::Z.avail_out = static_cast<uInt>(requestSize);
2925
2926 do
2927 {
2928 if (this->Superclass::Z.avail_in == 0)
2929 {
2930 this->Superclass::Z.next_in = this->Superclass::Inbuf;
2931 this->Superclass::Z.avail_in = static_cast<uInt>(
2932 fread(this->Superclass::Inbuf, 1, this->InputBufferSize, this->Superclass::File));
2933 if (ferror(this->Superclass::File))
2934 {
2935 this->ThrowStackTrace("failed in fread()");
2936 }
2937#if VTK_OPENFOAM_TIME_PROFILING
2938 this->Bytes += this->Superclass::Z.avail_in;
2939#endif
2940 }
2941 this->Superclass::ZStatus = inflate(&this->Superclass::Z, Z_NO_FLUSH);
2942 if (this->Superclass::ZStatus == Z_STREAM_END
2943#if VTK_FOAMFILE_OMIT_CRCCHECK
2944 // the dummy CRC function causes data error when finalizing
2945 // so we have to proceed even when a data error is detected
2946 || this->Superclass::ZStatus == Z_DATA_ERROR
2947#endif
2948 )
2949 {
2950 break;
2951 }
2952 if (this->Superclass::ZStatus != Z_OK)
2953 {
2954 throw this->StackString() << "Inflation failed: "
2955 << (this->Superclass::Z.msg ? this->Superclass::Z.msg : "");
2956 }
2957 } while (this->Superclass::Z.avail_out > 0);
2958
2959 size = requestSize - this->Superclass::Z.avail_out;
2960 }
2961 else
2962 {
2963 // not compressed
2964 size = fread(buf, 1, requestSize, this->Superclass::File);

Callers 2

ReadMethod · 0.95
ReadNextMethod · 0.95

Calls 3

ThrowStackTraceMethod · 0.95
StackStringMethod · 0.95
countMethod · 0.45

Tested by

no test coverage detected