Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,769,208 Members 37,834 Now Online
XDA Developers Android and Mobile Development Forum

[Q] os.path.getsize on android returns incorrect value

Tip us?
 
Jaman42
Old
(Last edited by Jaman42; 17th April 2014 at 05:45 PM.)
#1  
Junior Member - OP
Thanks Meter 0
Posts: 10
Join Date: Apr 2014
Default [Q] os.path.getsize on android returns incorrect value

Hi,
I found out that os.path.getsize in python doesn't give me the correct size of large files. Smaller files (I tried a 700mb) works fine but if I run it on larger files (+4GB) I get 394 005 664 bytes which is far from correct. If I run the command "ls -lh" in Android on the same large file I get roughly 375mb. Whats wrong? It's obviously having a hard time handling the large files but is there any workaround for this?

Edit: If I run ls -lsh I get 4579076, is that occupied space in kb?

Edit: stat -c %s gives me 4688972960, and that is correct. But in Python os.stat('path').st_size gives me 394005664

Edit: I am going all in testing now
Code:
f = open("filepath")
old_file_position = f.tell()
f.seek(0, os.SEEK_END)
size = f.tell()
f.seek(old_file_position, os.SEEK_SET)
also gives me 394005664

Edit: So guess I have to use stat -c %s for now, but I can't understand why os.path.getsize and ls -lh is giving me these values
 
Jaman42
Old
#2  
Junior Member - OP
Thanks Meter 0
Posts: 10
Join Date: Apr 2014
Default 2449955366

Anyone knows why this is happening?
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes