MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0030403Community[OCCT] OCCT:Application Frameworkpublic2018-12-10 16:282019-07-12 17:50
ReporterBenjaminBihler 
Assigned Tompv 
PrioritynormalSeverityminor 
StatusresolvedResolutionopen 
PlatformMingw-w64OSWindowsOS Version7
Product Version[OCCT] 7.3.0 
Target Version[OCCT] 7.4.0*Fixed in Version 
Summary0030403: Application Framework - Overwriting Big "BinOcaf" Files Does Not Reduce Their Size
DescriptionIf 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 ReproduceNot done yet
TagsNo tags attached.
Test case number
Attached Files

- Relationships

-  Notes
(0085588)
BenjaminBihler (developer)
2019-07-11 10:25

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?
(0085590)
mpv (developer)
2019-07-11 10:37

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.
(0085592)
git (administrator)
2019-07-11 12:18

Branch CR30403 has been created by BenjaminBihler.

SHA-1: 1d747136ea931d15e173eb3668b16b1361da1136


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.
(0085593)
BenjaminBihler (developer)
2019-07-11 12:24

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.

- Issue History
Date Modified Username Field Change
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
Powered by Mantis Bugtracker