Kodi Community Forum
Fail to read and write file using xbmcvfs.File in Frodo - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Fail to read and write file using xbmcvfs.File in Frodo (/showthread.php?tid=145013)

Pages: 1 2 3


RE: Fail to read and write file using xbmcvfs.File in Frodo - Popeye - 2013-01-08

Hmm, writing of a null byte is a absolute must for me...


RE: Fail to read and write file using xbmcvfs.File in Frodo - jmarshall - 2013-01-09

The current API can handle binary files as long as there's a null byte at the end of the file (albeit clumsily - split binary file into segments separated by the null bytes there-of), but can't handle writing a text file.

The proposed change will handle writing text files but won't handle binary files.

The only way to handle binary files is to have a size passed into the write() function along with the buffer.


RE: Fail to read and write file using xbmcvfs.File in Frodo - Popeye - 2013-01-09

(2013-01-09, 00:09)jmarshall Wrote: The only way to handle binary files is to have a size passed into the write() function along with the buffer.

If that will work I'm ok.



RE: Fail to read and write file using xbmcvfs.File in Frodo - guitardood - 2013-01-09

Actually the current API cannot handle binary that has any null bytes included (i.e. (\xa5\xa3\x00\xa5\xb3), the write would stop at the null byte due to it's use of 'strlen' to determine the buffer's size. This really should have a byte buffer with a length to be useful for binary files, however, I thought that API changes to frodo were frozen and that only fixes were being allowed for now? Ronie's update at least accomplishes making the API perform as documented: http://mirrors.xbmc.org/docs/python-docs/xbmcvfs.html#File-write

Technically the 'null' byte is not part of the buffer but a programmatic signal as to the end of the buffer and should never be included as part of the data.

BTW, thanks Ronie for making the change.

Best,
guitardood


RE: Fail to read and write file using xbmcvfs.File in Frodo - jmarshall - 2013-01-09

Not to belabor the point, but:

Quote:albeit clumsily - split binary file into segments separated by the null bytes there-of

You'd do that on the python side and send the segments without the null bytes.

The bigger point is that we cannot fix it for all binary writing without changing the API. I suspect this is unacceptable at this point in the release cycle, thus fixing the ascii writing at least gets one of them working.


RE: Fail to read and write file using xbmcvfs.File in Frodo - Popeye - 2013-01-09

I'm not really following but adding a optional size to write(buffer [,size]) whit the limitation that if not size is specified, null bytes will not be written?


RE: Fail to read and write file using xbmcvfs.File in Frodo - Popeye - 2013-01-30

https://github.com/xbmc/xbmc/pull/2053 screwed up binary writing. This completely ruins my addon...


RE: Fail to read and write file using xbmcvfs.File in Frodo - ronie - 2013-01-30

did it work in xbmc eden?


RE: Fail to read and write file using xbmcvfs.File in Frodo - Popeye - 2013-01-30

Eh, no... Blush I was using the "experimental" xbmcvfs.write to be able to write to nfs/smb shares. I just solved it by writing the files locally and then use xbmcvfs.copy(). Not as nice and general but it works....




RE: Fail to read and write file using xbmcvfs.File in Frodo - Nuka1195 - 2013-03-11

There seems to be issues with read() with the most recent changes.

all thats thrown in python is.

Quote:10:33:21 T:1152 NOTICE: Unknown exception thrown from the call "read"



RE: Fail to read and write file using xbmcvfs.File in Frodo - ronie - 2013-03-12

(2013-03-11, 16:27)Nuka1195 Wrote: There seems to be issues with read() with the most recent changes.

all thats thrown in python is.

Quote:10:33:21 T:1152 NOTICE: Unknown exception thrown from the call "read"

fix pending:
2425 (PR)


RE: Fail to read and write file using xbmcvfs.File in Frodo - Nuka1195 - 2013-03-12

https://github.com/xbmc/xbmc/commit/5caeccaf0ced28c083a8a3bbb16a2e78e63658d5

didn't fix my issue. i'm trying to read text files written with xbmcvfs.write() am i suppose to use readBytes() now for text files. i can supply a text file, but it's just text. Smile


RE: Fail to read and write file using xbmcvfs.File in Frodo - Nuka1195 - 2013-03-12

Quote:15:36:59 T:1320 NOTICE: Negative size passed to PyByteArray_FromStringAndSize

is what i get with readBytes()


RE: Fail to read and write file using xbmcvfs.File in Frodo - ronie - 2013-03-12

mind posting a comment about it on the PR?