Re: Recursive proc/check file size
- From: Neil Madden <nem@xxxxxxxxxxxxx>
- Date: Thu, 22 May 2008 14:34:31 +0100
Cameron Laird wrote:
In article <HdydnXOmic_KJ7LVnZ2dnUVZ8j6dnZ2d@xxxxxx>,
Neil Madden <nem@xxxxxxxxxxxxx> wrote:
.
.
.
If you only need to check the previous size, then you don't need a list -- just an extra parameter. Also, if you combine the last two lines then you can use the event loop so that (a) you don't keep consuming stack space which each recursive call, and (b) you can potentially do other tasks while this loop is running:
proc checksize {myfile {prevsize 0}} {
set filesize [file size $myfile]
puts $filesize
if {$filesize > 0 && $filesize == $prevsize} {
puts "all done"
} else {
after 1000 [list checksize $myfile $filesize]
}
}
...
checksize $myfile
vwait forever ;# not needed if Tk is running
-- Neil
Excellent advice.
I'm a tiny bit concerned that filesize on the first invocation
might be zero--do you see the difficulty I do?
Isn't this what the $filesize > 0 guard is for? (I took that directly from Kevin's original code).
-- Neil
.
- Follow-Ups:
- Re: Recursive proc/check file size
- From: newtophp2000
- Re: Recursive proc/check file size
- References:
- Recursive proc/check file size
- From: Kevin Walzer
- Re: Recursive proc/check file size
- From: Neil Madden
- Re: Recursive proc/check file size
- From: Cameron Laird
- Recursive proc/check file size
- Prev by Date: PDF attachment
- Next by Date: Re: Recursive proc/check file size
- Previous by thread: Re: Recursive proc/check file size
- Next by thread: Re: Recursive proc/check file size
- Index(es):
Relevant Pages
|