1. RE: W2K problem with walk_dir?
You don't have a problem. I'm guessing what you have is your console window
simply not staying open at the end of the program, so you don't see the
results. I noticed this behavior too when I started using EUPHORIA in Win2K.
Use the following code (I cleaned it up a bit and made a provision for
having fewer than 25 directories) and it will probably work for you:
--- Walk down directories, count files per directory, get largest dirs
with trace
trace(0)
include file.e
include get.e
include sort.e
object junk
constant TRUE=1
integer dir_count,
subdir_filecount
dir_count = 0
subdir_filecount = 0
sequence dirs,
start_dir
dirs = { }
start_dir = prompt_string("Enter the top dir and press enter.\n")
atom start_time,
end_time,
total_time,
num_dirs
start_time = time()
printf (1,"Start time:%d\n",{start_time})
-- This function accepts two sequences as arguments
function look_at(sequence path_name, sequence entry)
---printf(1, "%s\\%s: %s\n", {path_name,
entry[D_NAME],entry[D_ATTRIBUTES]})
sequence this_dir, subdir
this_dir = ""
if find ('d', entry[D_ATTRIBUTES] ) then
dir_count += 1
this_dir = path_name & "\\" & entry[D_NAME]
--printf (1, "File:%s\n", this_dir)
subdir = dir(this_dir)
subdir_filecount = 0
for i = 1 to length(subdir) do
if find(".",{subdir[i][D_NAME]}) or find("..",{subdir[i][D_NAME]}) or
find("d",{subdir[i][D_ATTRIBUTES]}) then
else
-- printf(1,"Sub File:%s\n", {subdir[i][D_NAME]})
subdir_filecount += 1
end if
end for
-- printf (1, "Dir:%s Files:%d\n", {this_dir, subdir_filecount})
dirs = append (dirs, {subdir_filecount,this_dir})
end if
return 0 -- keep going
end function
-- Call routine to walk dir ---
if walk_dir(start_dir, routine_id("look_at"), TRUE) then
end if
-- Print total amount of files found with archive bit reset --
printf (1, "TOTAL sub-directories:%d\n", {dir_count})
puts (1,"\nTop 25:\n")
dirs = sort (dirs)
dirs = reverse(dirs)
num_dirs = length(dirs) -- I was using c:\euphoria, so I didn't HAVE 25
items.
if num_dirs > 25 then -- Just in case you have billions.
num_dirs = 25
end if
for i = 1 to num_dirs do
printf (1, "File count:%d, Dir:%s\n", dirs[i])
end for
-- end time
end_time = time()
total_time = end_time - start_time
printf (1,"Total time:%d\n",{total_time})
junk = wait_key() -- this allows us to see the results!
2. RE: W2K problem with walk_dir?
- Posted by lists at wordit.com
Jan 29, 2002
On 29.01.02 at 20:01 C. K. Lester wrote:
>I'm guessing what you have is your console window
>simply not staying open at the end of the program...
No it's that. I did add that code. He actually gets an error message.
However, it only happens for root, i.e. C:\, not with subdirectories.
Could you try with C:\ ?
The error message is:
TEST.EX:42 in function look_at()
type_check failure, subdir is -1
called from file.e:194 in function walk_dir()
called from TEST.EX:65
The line numbers may differ now, but line 65 is the one calling the
look_at function. It seems that walk_dir itself is causing a problem.
Thanks,
Marcus
3. RE: W2K problem with walk_dir?
Well, you'll be interested to know that it worked for me!
It took a "Total Time" of 23 (seconds?).
I used c: for the top directory. Maybe the slash is causing problems...
No, I just tried it using "c:\" and it worked just fine... Except, in this
case, it only took 2 seconds!!!!
WTF??? (Why the frequency?) :)
Anyway, have fun with it. ;)
> -----Original Message-----
> From: lists at wordit.com [mailto:lists at wordit.com]
> Sent: Tuesday, January 29, 2002 9:46 PM
> To: EUforum
> Subject: RE: W2K problem with walk_dir?
>
>
>
> On 29.01.02 at 20:01 C. K. Lester wrote:
> >I'm guessing what you have is your console window
> >simply not staying open at the end of the program...
>
> No it's that. I did add that code. He actually gets an error message.
> However, it only happens for root, i.e. C:\, not with subdirectories.
> Could you try with C:\ ?
>
> The error message is:
>
> TEST.EX:42 in function look_at()
> type_check failure, subdir is -1
> called from file.e:194 in function walk_dir()
> called from TEST.EX:65
>
> The line numbers may differ now, but line 65 is the one calling the
> look_at function. It seems that walk_dir itself is causing a problem.
>
> Thanks,
>
> Marcus
>
>
>
4. RE: W2K problem with walk_dir?
The second time you ran most of the file data required would have been in
cache so would be accessible far faster than going to disk a second time.
Try rebooting before each run - the timings should be similar.
Regards,
FP.
At 10:48 PM 1/29/02 -0600, you wrote:
>
>Well, you'll be interested to know that it worked for me!
>
>It took a "Total Time" of 23 (seconds?).
>
>I used c: for the top directory. Maybe the slash is causing problems...
>
>No, I just tried it using "c:\" and it worked just fine... Except, in this
>case, it only took 2 seconds!!!!
>
>WTF??? (Why the frequency?) :)
>
>Anyway, have fun with it. ;)
>
>> -----Original Message-----
>> From: lists at wordit.com [mailto:lists at wordit.com]
>> Sent: Tuesday, January 29, 2002 9:46 PM
>> To: EUforum
>> Subject: RE: W2K problem with walk_dir?
>>
>>
>> On 29.01.02 at 20:01 C. K. Lester wrote:
>> >I'm guessing what you have is your console window
>> >simply not staying open at the end of the program...
>>
>> No it's that. I did add that code. He actually gets an error message.
>> However, it only happens for root, i.e. C:\, not with subdirectories.
>> Could you try with C:\ ?
>>
>> The error message is:
>>
>> TEST.EX:42 in function look_at()
>> type_check failure, subdir is -1
>> called from file.e:194 in function walk_dir()
>> called from TEST.EX:65
>>
>> The line numbers may differ now, but line 65 is the one calling the
>> look_at function. It seems that walk_dir itself is causing a problem.
>>
>> Thanks,
>>
>> Marcus
>>
>>
>
>
>