1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00
* Solves #11156

* Check file size for all file format. Disable APPEND if file is empty

* Add test for APPEND mode
This commit is contained in:
LaurentBerger
2018-03-28 14:35:38 +02:00
committed by Vadim Pisarevsky
parent 75b5e3fa64
commit 03eb463f1c
2 changed files with 24 additions and 2 deletions
+6 -2
View File
@@ -206,8 +206,12 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
// and factor=4 for YAML ( as we use 4 bytes for non ASCII characters (e.g. \xAB))
int buf_size = CV_FS_MAX_LEN*(fs->fmt == CV_STORAGE_FORMAT_XML ? 6 : 4) + 1024;
if( append )
if (append)
{
fseek( fs->file, 0, SEEK_END );
if (ftell(fs->file) == 0)
append = false;
}
fs->write_stack = cvCreateSeq( 0, sizeof(CvSeq), fs->fmt == CV_STORAGE_FORMAT_XML ?
sizeof(CvXMLStackRecord) : sizeof(int), fs->memstorage );
@@ -301,7 +305,7 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
}
else if( fs->fmt == CV_STORAGE_FORMAT_YAML )
{
if( !append )
if( !append)
icvPuts( fs, "%YAML:1.0\n---\n" );
else
icvPuts( fs, "...\n---\n" );