Posts: 964
Joined: Aug 2009
Reputation:
27
Popeye
Posting Freak
Posts: 964
Well I manged to read 1024 bytes of a rar file header and write this locally (i.e. using open(file, 'wb') ). I also manged to write binary data except the \x00 ...
Posts: 492
Joined: Dec 2006
Reputation:
5
There seems to be some confusion here. I could trivially remove the null character from the write method and you guys will be happy but the question is really, what does it mean to write a string (python string vs const char* vs some other representation) to a file. It will depend on the language. If the API is in terms of binary data for both read and write then it becomes language independent. That's the way I would prefer to address this.
Hope that helps.
Posts: 964
Joined: Aug 2009
Reputation:
27
Popeye
Posting Freak
Posts: 964
Binary is the way to go, imho
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
2012-11-15, 18:13
(This post was last modified: 2012-11-15, 18:17 by Nuka1195.)
the append "bOverWrite=false" does work, you just appear not to seek to the end of the file.
if you take standard text editors "windows" notepad and wordpad, they do not strip the \x00 from the file, so it seems to me it should not be written to the file for any language. wouldn't you agree? the extra character causes issues when manually (in notepad) editing a text file. not something i can't handle, but i don't believe it should be in the file.
if the only way you want to handle it is for the python script to set the length (if the pythons api is not separate from other languages) then ok, if the pythons api is a separate .cpp. then really i believe it should be handled in the .cpp to be more like pythons' write().
edit: maybe support "wb" and "rb" then ignore \x00 only if "w", "r"?
Posts: 11
Joined: May 2012
Reputation:
1
I try to write downloaded video files this way - so as you can image this is also a big problem for me. I'd prefer to have something like 'wb' and 'rb' as described above.
Posts: 492
Joined: Dec 2006
Reputation:
5
No no. Sorry. It was late - I should have realized it was confusing
Basically the File::read/write methods are now in terms of a buffer class which maps to a python bytearray. The write can take a bytearray or a string (if it's a string it wont write the null) and the read returns a bytearray.
Sorry for the confusion.
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
so we don't set that with "w" or "wb".
is there any plans to add append "a" ability? the bOverWrite=false works, but when set to false, you do not seek to the end of the file, you just replace the file from the beginning.
Posts: 32
Joined: Jul 2011
Reputation:
0
Bump! Seeing as how feature changes are frozen for Frodo, can whoever the maintainer is for this fix the one line of code before Frodo is released?
Posts: 32
Joined: Jul 2011
Reputation:
0
2013-01-08, 20:08
(This post was last modified: 2013-01-08, 20:17 by guitardood.)
Popeye, don't know how, but I will try.
Thanks,
guitardood
EDIT: Actually it appears that Nuka1195 created ticket 13545 on 11/13/2012 which is still open with no activity in 8 weeks.
EDIT2: I reposted my message from above with the relevant code change required to the ticket. Hopefully this can be fixed while discussion continues on improvements/modifications to the code's behavior.