decalage2 / olefile

olefile is a Python package to parse, read and write Microsoft OLE2 files (also called Structured Storage, Compound File Binary Format or Compound Document File Format), such as Microsoft Office 97-2003 documents, vbaProject.bin in MS Office 2007+ files, Image Composer and FlashPix files, Outlook messages, StickyNotes, several Microscopy file formats, McAfee antivirus quarantine files, etc.
http://www.decalage.info/olefile
Other
231 stars 77 forks source link

write_stream: data must be the same size as the existing stream #146

Closed X3msnake closed 2 years ago

X3msnake commented 2 years ago

image

Greetings, on the Docs it's says from version 0.45 onwards it can write any size stream, but i'm getting the above error in the following script, what am i doing wrong?

>>> ole_ok = olefile.OleFileIO('ok.crv3d')
>>> print(ole_ok.listdir())
[['ModelObjects', 'ObjectData'], ['PreviewData', 'Preview2D_GIF'], ['Toolpaths', 'Simulation'], ['Toolpaths', 'ToolpathData'], ['Toolpaths', 'ToolpathPosData'], ['VectorData', '2dDataV2'], ['VectorData', 'DocumentData'], ['VectorData', 'MaterialSize'], ['VersionData', 'Version']]
>>> ole_ok_data = ole_ok.openstream('VersionData/Version').read()
>>> ole = olefile.OleFileIO('nok.crv3d', write_mode=True)
>>> ole.write_stream('VersionData/Version', ole_ok_data)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Utilizador\AppData\Local\Programs\Python\Python38\lib\site-packages\olefile\olefile.py", line 1951, in write_stream raise ValueError("write_stream: data must be the same size as the existing stream") ValueError: write_stream: data must be the same size as the existing stream
decalage2 commented 2 years ago

Hi, indeed the text in the doc is confusing: the new stream must always have the same size as the existing stream. What changed in olefile v0.45 is just that it is able to write large streams (from the FAT) and small streams (from the MiniFAT), so streams of all sizes can be written. But their size cannot be changed. I need to clarify the doc about this, so I'll keep this issue open.

X3msnake commented 2 years ago

Thanks for the fast reply master

Do you have plans to implement the ability to write a different size stream. I was so close to make a patcher for some old files i have that need a replacement of a stream but I 've hit a dead end with this limitation :\ and my skills are not enough to even know how to go around this current limitation.

Can you share some light on to what i must do?

Philippe Lagadec @.***> escreveu no dia terça, 7/12/2021 à(s) 09:44:

Hi, indeed the text in the doc is confusing: the new stream must always have the same size as the existing stream. What change in olefile v0.45 is just that it is able to write large streams (from the FAT) and small streams (from the MiniFAT), so streams of all sizes can be written. But their size cannot be changed. I need to clarify the doc about this, so I'll keep this issue open.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/decalage2/olefile/issues/146#issuecomment-987746319, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUR56V5LV4VOXIVLCA3C5LUPXJRLANCNFSM5JPEKFJQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Com os melhores cumprimentos, Vinicius Silva

decalage2 commented 2 years ago

Implementing it requires a lot of work in many places of the library, it's a major redesign. I summarized the steps in this issue: https://github.com/decalage2/olefile/issues/6 Unfortunately, I do not have the spare time to work on it for the moment. Any help would be appreciated, of course.

X3msnake commented 2 years ago

Thanks for your work, wish i knew how to help.

Philippe Lagadec @.***> escreveu no dia terça, 7/12/2021 à(s) 12:25:

Implementing it requires a lot of work in many places of the library, it's a major redesign. I summarized the steps in this issue: #6 https://github.com/decalage2/olefile/issues/6 Unfortunately, I do not have the spare time to work on it for the moment. Any help would be appreciated, of course.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/decalage2/olefile/issues/146#issuecomment-987878152, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUR56WZABRVDGUMNJNYEOLUPX4JZANCNFSM5JPEKFJQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Com os melhores cumprimentos, Vinicius Silva