get size of file in localfs
Hi, I am using the following statements in order the filesize. file = container.REQUEST.form['FILE'] filesize = len(file.read()) When getting the size of large files it takes a long time to calculate. Is there another (fast) way to get the filesize in a python script ? Regards, Michael
Michael Bleijerveld wrote:
file = container.REQUEST.form['FILE'] filesize = len(file.read()) When getting the size of large files it takes a long time to calculate.
Is there another (fast) way to get the filesize in a python script ?
What do you need to know the length of the file for? cheers, Chris
For calculating if the user reaches the diskquota. Greetings. Michael ----- Original Message ----- From: "Chris Withers" <chrisw@nipltd.com> To: "Michael Bleijerveld" <michael@bleijerveld.nl> Cc: <zope@zope.org> Sent: Friday, July 18, 2003 4:35 PM Subject: Re: [Zope] get size of file in localfs
Michael Bleijerveld wrote:
file = container.REQUEST.form['FILE'] filesize = len(file.read()) When getting the size of large files it takes a long time to calculate.
Is there another (fast) way to get the filesize in a python script ?
What do you need to know the length of the file for?
cheers,
Chris
Michael Bleijerveld wrote:
For calculating if the user reaches the diskquota.
You can use seek and tell, I'm not really sure if its "safe" but thats what I did in the re-write of the zope examples to enforce an after-the-fact filesize limit. -- Jamie Heilman http://audible.transient.net/~jamie/ "We must be born with an intuition of mortality. Before we know the words for it, before we know there are words, out we come bloodied and squalling with the knowledge that for all the compasses in the world, there's only one direction, and time is its only measure." -Rosencrantz
participants (3)
-
Chris Withers -
Jamie Heilman -
Michael Bleijerveld