1. Subdirectory

Hello coders,

include file.e 
    integer a 
    sequence myfolder 
    --myfolder=any folder 
function look_at(sequence path_name, sequence entry)-- this function accepts two sequences as arguments 
                printf(1, "%s\\%s: \n", 
                 {path_name, entry}) 
                  return 0 -- keep going 
end function 
 
    a = walk_dir(myfolder, routine_id("look_at"), 1) 
     
--- i1 = walk_dir(st, i2, i3) 
--   Description: This routine will "walk" through a directory with path name given 
--                 by st. i2 is the routine id of a routine that you supply. 
    --            walk_dir() will call your routine once for each file and 
    --            subdirectory in st. If i3 is non-zero (TRUE), then the 
    --            subdirectories in st will be walked through recursively. 
 

This prints out all files in the directory but I don't see any sub directories.

What's wrong?

Don Cole

new topic     » topic index » view message » categorize

2. Re: Subdirectory

Hi, Probably the walk_dir you are picking up via file.e is not the same one thats in win32lib?
when I change the include file.e to include win32lib.ew it works.

HTH!

Regards
Alan

new topic     » goto parent     » topic index » view message » categorize

3. Re: Subdirectory

You are using the wrong version of walk_dir().

From your look_at() function, it seems you want the 4.0 version of walk_dir() in std/filesys.e not the 3.1 version in file.e

dcole said...

Hello coders,

include file.e 
    integer a 
    sequence myfolder 
    --myfolder=any folder 
function look_at(sequence path_name, sequence entry)-- this function accepts two sequences as arguments 
                printf(1, "%s\\%s: \n", 
                 {path_name, entry}) 
                  return 0 -- keep going 
end function 
 
    a = walk_dir(myfolder, routine_id("look_at"), 1) 
     
--- i1 = walk_dir(st, i2, i3) 
--   Description: This routine will "walk" through a directory with path name given 
--                 by st. i2 is the routine id of a routine that you supply. 
    --            walk_dir() will call your routine once for each file and 
    --            subdirectory in st. If i3 is non-zero (TRUE), then the 
    --            subdirectories in st will be walked through recursively. 
 

This prints out all files in the directory but I don't see any sub directories.

What's wrong?

Don Cole

new topic     » goto parent     » topic index » view message » categorize

4. Re: Subdirectory

Thanks Jim and Alan,

This shows the subfolders but does not show the files within. Isn't there a progam in the archines or somewhere that would list everyfile in a given folder or drive?

I would think a recursive program.

Don Cole

new topic     » goto parent     » topic index » view message » categorize

5. Re: Subdirectory

wd40 said...

Thanks Jim and Alan,

This shows the subfolders but does not show the files within. Isn't there a progam in the archines or somewhere that would list everyfile in a given folder or drive?

I would think a recursive program.

Don Cole

Yes, my "WalkDir.exw" from Win32Lib demos does that.

Uses "walk_dir" *twice*; first to put into a list just the files (not the directories)in the target directory; then used again to recursively put all the directories and all their files in the same list

And don't forget to check out "RunDemos", that's how I located "WalkDir.exw"

Dan

new topic     » goto parent     » topic index » view message » categorize

6. Re: Subdirectory

The following code is what works for me, it shows each file with its full path, size, and flags:

include win32lib_ajo.ew  -- v0.70.4a June 2008 (modified, routine to routine_name) 
 
function ShowFilesAndDirs(sequence path_name, sequence ItemEntry) 
sequence DirMarker, s1, s2, s3, s4, s5, s6 
    -- Let Windows get a chance. 
    doEvents(0) 
    -- SET A MARKER TO SHOW IN LIST IF FOUND A DIRECTORY: 
    if equal(ItemEntry[D_ATTRIBUTES], "d") then 
      DirMarker = "\\" 
     else 
      DirMarker = "" 
      s1 = ItemEntry 
    end if 
    s1 = sprintf("%04d",{ItemEntry[4]})   -- year 
    s2 = sprintf("%02d",{ItemEntry[5]})   -- month 
    s3 = sprintf("%02d",{ItemEntry[6]})   -- day 
    s4 = sprintf("%012d",{ItemEntry[3]})  -- size, up to 99Gb 
    s6 = ItemEntry[2]                     -- file flags shrd 
    while length(s6) < 6 do 
      s6 = s6 & " " 
    end while 
    s5 = DirMarker -- suppress <0322> 
    s5 = s6   -- attributes 
    s5 = s5 & "       " -- open space for backup flags 
    s5 = s5 & s4 
    s5 = s5 & " " & s1 & s2 & s3 
    s5 = s5 & " " & path_name & "\\" 
    s5 = s5 & ItemEntry[1] -- filename 
    puts(allfiles,s5 & "\n") 
    return 0 --Stopped  -- keep going (return a non-zero to stop it) 
end function 
 
scanned_flag = walk_dir(drive_letter, routine_id("ShowFilesAndDirs"),1) 
 
new topic     » goto parent     » topic index » view message » categorize

7. Re: Subdirectory

Hello Dan,

Thank you very much that.s exactly what I'm looking for.

And thank you Alan for responding. i'm looking into your code.

Don Cole

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu