It seems that DirEntry's f.stat().st_size can return values larger than 2147483647 for the file size, which - in my case - is correct. But when I try to store it in a Gtk.ListStore which has the corresponding column set to int, I get an OverflowError:
OverflowError: 2200517068 not in range -2147483648 to 2147483647
How do I solve this? Is int in ListStore limited to 4 bytes?
BTW, I'm using Python 3.9.5 and GUdev 237.
self.file_store = Gtk.ListStore(str, # File name
int, # File size
str) # Mod time, as YYYY/MM/DD hh:mm:ss
...
self.file_store.append(
(f.name,
f.stat().st_size,
ftime))
Use
GObject.TYPE_INT64to allow signed 64-bit integers in the list store:You will probably want signed 64-bit integers given that
off_t(whatst_sizeis defined as) is defined to be a signed type, and on most platforms it is at most 64 bits wide; 8 pebibytes ought to be enough for everyone.You can refer to other primitive GObject types in similar way, using
TYPE_nameconstants in theGObjectnamespace.