|Anonymous | Login||2019-07-16 07:52 MSK|
|My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0030403||Community||[OCCT] OCCT:Application Framework||public||2018-12-10 16:28||2019-07-12 17:50|
|Product Version||[OCCT] 7.3.0|
|Target Version||[OCCT] 7.4.0*||Fixed in Version|
|Summary||0030403: Application Framework - Overwriting Big "BinOcaf" Files Does Not Reduce Their Size|
|Description||If I have a big document file here and I overwrite it with a small document file, then everything works fine except that the file size isn't reduced. If I store it to a new file, the file size is as small as expected.|
The solution is to add "std::ios::trunc" to the mode of the line
OSD_OpenStream (aFileStream, theFileName, std::ios::out | std::ios::binary);
which is here line 74 of BinLDrivers_DocumentStorageDriver.cxx. I guess that it would be the best to add "std::ios::trunc" to all calls to OSD_OpenStream where the mode contains the bit "std::ios::out".
Note: I use Mingw-w64 here, but I guess that this doesn't cause a difference.
|Steps To Reproduce||Not done yet|
|Tags||No tags attached.|
|Test case number|
I have been disappointed to see that the target version has been set to 7.5.0. This issue should be quick and easy to fix.
According to https://en.cppreference.com/w/cpp/io/ios_base/openmode, [^] "std::ios::trunc" discards the contents of the stream when opening, so there shouldn't be any drawback when overwriting files.
Would you reconsider this issue, if I commited a proposal for the fix? Or do you have a reason to expect the issue to be more complex?
|Proposal for the fix would be appreciated. Fix of this issue also supposes non-regression test creation, which is quite expensive for such a minor issue.|
Branch CR30403 has been created by BenjaminBihler.
Detailed log of new commits:
Author: Benjamin Bihler
Date: Thu Jul 11 11:16:12 2019 +0200
0030403: Overwriting Big "BinOcaf" Files Does Not Reduce Their Size
Added std::ios::trunc to all file open modes used for writing.
While implementing and checking the fix, I have realized that this is even more than a minor issue. XmlLDrivers_DocumentStorageDriver and VrmlAPI_Writer have been writing text files without truncating the output stream. In this case when overwriting large files, parts of the old files were still there, leading most probably to wrong output files (the remainders of old large files have been seemingly ignored with BinOcaf files).
Since I am not really familiar with writing test scripts, I won't do that, sorry.
|2018-12-10 16:28||BenjaminBihler||New Issue|
|2018-12-10 16:28||BenjaminBihler||Assigned To||=> mpv|
|2019-07-10 09:01||abv||Target Version||7.4.0* => 7.5.0|
|2019-07-11 10:25||BenjaminBihler||Note Added: 0085588|
|2019-07-11 10:37||mpv||Note Added: 0085590|
|2019-07-11 12:18||git||Note Added: 0085592|
|2019-07-11 12:24||BenjaminBihler||Note Added: 0085593|
|2019-07-11 12:24||BenjaminBihler||Status||new => resolved|
|2019-07-11 12:24||BenjaminBihler||Steps to Reproduce Updated||View Revisions|
|2019-07-11 14:34||kgv||Summary||Overwriting Big "BinOcaf" Files Does Not Reduce Their Size => Application Framework - Overwriting Big "BinOcaf" Files Does Not Reduce Their Size|
|2019-07-12 17:50||abv||Target Version||7.5.0 => 7.4.0*|
|Copyright © 2000 - 2019 MantisBT Team|