1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

core: safe handling of compressed file level extension (.gz[0-9])

- Replace unsafe pointer arithmetic and direct buffer modification with std::string methods.
- Update documentation to clarify that the last digit is used as compression level and truncated from the actual filename.
- Add test cases for .gz and .gz0-9
This commit is contained in:
Kumataro
2026-05-05 07:41:59 +09:00
parent 5cbfe53798
commit 8449b9e468
3 changed files with 42 additions and 13 deletions
@@ -306,8 +306,12 @@ public:
before opening the file.
@param filename Name of the file to open or the text string to read the data from.
Extension of the file (.xml, .yml/.yaml or .json) determines its format (XML, YAML or JSON
respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both
FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify
respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz.
You can also specify a compression level from 0 to 9 by appending it to the extension
(e.g. ".gz0" for no compression, ".gz9" for high compression).
The last digit will be truncated internally to write/read.
(e.g. If "a.xml.gz9" is specified, "a.xml.gz" is used for the actual file name.)
If both FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify
the output file format (e.g. mydata.xml, .yml etc.). A file name can also contain parameters.
You can use this format, "*?base64" (e.g. "file.json?base64" (case sensitive)), as an alternative to
FileStorage::BASE64 flag.