1. Subdirectory
- Posted by dcole Jan 10, 2010
- 1083 views
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
2. Re: Subdirectory
- Posted by alanjohnoxley Jan 12, 2010
- 1010 views
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
3. Re: Subdirectory
- Posted by jimcbrown (admin) Jan 12, 2010
- 998 views
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
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
4. Re: Subdirectory
- Posted by wd40 Jan 14, 2010
- 947 views
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
5. Re: Subdirectory
- Posted by DanM Jan 14, 2010
- 951 views
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
6. Re: Subdirectory
- Posted by alanjohnoxley Jan 14, 2010
- 976 views
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)
7. Re: Subdirectory
- Posted by wd40 Jan 15, 2010
- 972 views
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