file.read() doesn't read the whole file
sreejithemk at gmail.com
Mon Mar 23 07:41:49 CET 2009
> Try and write an example that shows the problem in fifteen lines or
> less. Much easier for us to focus on the issue that way.
def read(length, offset):
snap = open('mango.txt_snaps/snap1/0','r')
data = snap.read(length)
This code shows what actually happens inside the code I've written.
This prints the 4096 bytes from the file '0' which is only 654 bytes.
When we run the code we get the whole file. That's right. I also get
it. But when this read() function becomes the file class read()
function in fuse, the data printed is not the whole but only a few
lines from the beginning. I usually use less to read a file, when
'less'ing a file (whose size is less than 4096bytes) a call to read
(0,4096) is made and data is returned. 'less' use this data returned
by my fuse read() function to display its contents. But it was
supposed to be the whole lines in the file like the example, but its
not.... This is the problem I'm facing. Did I do something wrong here ?
More information about the Python-list