Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who's Online
1 user(s) are online (1 user(s) are browsing Forum)

Members: 0
Guests: 1

more...

Browsing this Thread:   1 Anonymous Users



(1) 2 »


Directory listing with wildcards

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1506
Offline
I tried compiling this example, but it didn't quite work as I expected. Recursive listing works with #?, but if I try to list something like AHX.#? or #?.c it won't list the content of the subdirectories. Is this the expected behavior, or it's a bug?

Posted on: 2012/11/3 7:28
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
Transfer the post to other applications Transfer


Re: Directory listing with wildcards

Joined:
2012/4/28 5:42
From Sweden
Group:
Member
Posts: 205
Offline
Well with shell's list command I use "list all s#?" to list all directories starting with an "s"

Posted on: 2012/11/3 9:00
_________________
To NSA: Hope you found my post interesting.
Transfer the post to other applications Transfer


Re: Directory listing with wildcards

Joined:
2011/6/30 19:50
Group:
Member
Posts: 4095
Offline
@bszili:

i have not tried the code myself. but in regards to snoopy's answer: although that indeed works, you will also notice that dir and list both are unable to do a recursive patternmatch. e.g. dir ALL #?.datatype on sys: will not show you anything when started from the root.

As a sidenote, it is the same behaviour as on original amigaOS 3.1

regards,

Posted on: 2012/11/3 21:23
Transfer the post to other applications Transfer


Re: Directory listing with wildcards

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1506
Offline
droopy & magorium: Alright, so this is the expected behavior. I wonder if it would break things if this limitation wasn't there. Ah well, it's better than nothing

Posted on: 2012/11/4 1:24
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
Transfer the post to other applications Transfer


Re: Directory listing with wildcards

Joined:
2011/6/30 19:50
Group:
Member
Posts: 4095
Offline
@bszili:

It could be that i misunderstood things, but it could be that this behaviour is the way it is because it applies the pattern to the directoryname as well.

When in fpc, i do two runs. One for the files (which matches the filenamepattern and when matched i then handle/print/or do whatever with them) and once again only checking for directories (without pattern match/match all). When a directory is found i call the same routine recursively.

Ofcourse all this with fpc routines, since i didn't had the time yet to translate that using only aros-routines.

regards,

Posted on: 2012/11/4 1:35
Transfer the post to other applications Transfer


Re: Directory listing with wildcards

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1506
Offline
Then I don't get it. It shouldn't limit itself to the current directory, even if it matches both files and directories. My problem is that recursive search only works if you don't specify a pattern, or only give #? as the pattern or somedir/#?.

Posted on: 2012/11/4 1:04
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
Transfer the post to other applications Transfer


Re: Directory listing with wildcards

Joined:
2011/6/30 19:50
Group:
Member
Posts: 4095
Offline
Quote:
Then I don't get it.

Please keep in mind, that i could be mistaken or that i misunderstood the code.

Quote:
It shouldn't limit itself to the current directory,

but imo the code you pointed to does. It matches a directory based upon the pattern. So if you would actually supply a pattern of e.g. #?.info then which directory would match that ? Exactly zero (unless you are develish and created such directory). on second thought, try creating it and see for yourself

Quote:
even if it matches both files and directories.

The files must match the pattern (e.g. #?.info) the directories must match #? (all).

Quote:
My problem is that recursive search only works if you don't specify a pattern, or only give #? as the pattern or somedir/#?.

Exactly the behaviour i was expecting.

So i am affraid we have a communication-problem here and I have no idea how to solve that :/

Ofcourse i can try to explain further if you want, perhaps we can solve the communication thingy toghether

regards,

Posted on: 2012/11/4 1:20
Transfer the post to other applications Transfer


Re: Directory listing with wildcards

Joined:
2011/6/30 19:50
Group:
Member
Posts: 4095
Offline
In an attempt to have the correct communicationprotocol

in pseusocode this is what i use:
procedure filesearch (pathnamefilenamestringRecursiveboolean);
Var
  
SRTSearchRec;
  
path string;

begin
  
first runwe take files from current pathname }
  
path := makesurepathdelimisthere(pathname);
  if 
findfirst(path filenameisafileonlySRthen
  repeat
    
check needed because of softlinks etc }
    If 
isafileandonlyafile then writeln (path SR.name);

  
until findnext(SR) <> 0;
  
FindClose(SR);

  { do 
we want to recurse ? }
  If 
not recusive then exit;

  { 
second rundirectories only }
  if 
findfirst(path '*'isadirectoySR) = 0 then
  repeat
    
If (SR.Attribute directory and directory onlythen filesearch (path SR.nameFilenameTrue);
  
until Findnext(SR) <> 0;

  
findclose(SR);
end;

Program test;
begin
  Filesearch
('ram:','*.info'true);
end.


Note the different search patterns when searching e.g. for a specfic extension. Ofcourse if you choose to search * as filename it will match all.

Perhaps that makes more sense ?

regards,

Posted on: 2012/11/4 1:52
Transfer the post to other applications Transfer


Re: Directory listing with wildcards

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1506
Offline
I think it does. I didn't really understand the API, what APF_DODIR and APF_DIDDIR means, etc. I still don't, but I'm a bit closer with your pascal example.

Posted on: 2012/11/4 4:24
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
Transfer the post to other applications Transfer


Re: Directory listing with wildcards

Joined:
2011/6/30 19:50
Group:
Member
Posts: 4095
Offline
@bszili:
again i might be mistaken and there is a simpler way of doing it. but this is how it's done in pascal.

Here is more info on amiga, the flags and how they should behave.

regards,

red: 156 hits in google sux :/ i found this and this, but am not sure if it will help you, so apologies upfront.

Posted on: 2012/11/4 4:36

Edited by magorium on 2012/11/4 5:41:45
Transfer the post to other applications Transfer



(1) 2 »



You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4340
2 magorium
magorium
4095
3 phoenixkonsole
phoenixkonsole
3887
4 nikolaos
nikolaos
3677
5 deadwood
deadwood
2923
6 ncafferkey
ncafferkey
2616
7 mazze
mazze
2207
8 clusteruk
clusteruk
2073
9 Kalamatee
Kalamatee
2023
10 damocles
damocles
1789
© 2004-2017 AROS Exec