Fail to read and write file using xbmcvfs.File in Frodo
#16
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 ...
Pneumatic | SABnzbd | XBMC that just works - openelec
Reply
#17
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.
Reply
#18
Binary is the way to go, imho
Pneumatic | SABnzbd | XBMC that just works - openelec
Reply
#19
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"?
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#20
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.
Reply
#21
Ok. Sorry it took so long.

Here is what I'm thinking. I'm not sure it works yet but you should get the idea.

https://github.com/jimfcarroll/xbmc/comm...f12f0bbb40
Reply
#22
Honestly I'm kind of lost Big Grin but I'll read up on the java buffer class to get a hang of it.
Pneumatic | SABnzbd | XBMC that just works - openelec
Reply
#23
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.
Reply
#24
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.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#25
What is the status? Cant find anything in latest sources... Big Grin
Pneumatic | SABnzbd | XBMC that just works - openelec
Reply
#26
In the follow function from 'xbmc/xbmc/interfaces/legacy/File.cpp':
Code:
bool File::write(const char* pBuffer)
    {
      DelayedCallGuard dg(languageHook);
      return file->Write( (void*) pBuffer, strlen( pBuffer ) + 1 ) > 0;
    }
the offending piece is the '+1' in the Write line adding 1 to the strlen(pBuffer). Unless writing the string null-terminator is by design, this should be corrected to remove the '+1'.
Any chance somebody could fix this? This is a great module, but with the nulls being written to the file, it is pretty much unusable.

Best,
guitardood
Reply
#27
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?
Reply
#28
(2013-01-08, 05:13)guitardood Wrote: 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?

Have you made a trac ticket? if not, please do
Pneumatic | SABnzbd | XBMC that just works - openelec
Reply
#29
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.

Reply
#30
2053 (PR)
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply

Logout Mark Read Team Forum Stats Members Help
Fail to read and write file using xbmcvfs.File in Frodo0