Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who is Online
24 user(s) are online (22 user(s) are browsing Forum)

Members: 0
Guests: 24

more...


Browsing this Thread:   1 Anonymous Users




(1) 2 »


Re: Directory listing with wildcards
#15
Home away from home
Home away from home


See User information
Quote:

BSzili wrote:
What I expected from recursively matching for AHX.#? was:
Quote:

Match AHX.#? for files in the current directory and every subdirectory.


List ALL PATTERN="AHX.#?" LFORMAT="%P%N"

Posted on: 2012/11/9 10:39
Everyone knew it was impossible. Along came a fool who did not know and he did it.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Directory listing with wildcards
#14
Home away from home
Home away from home


See User information
Hi BSzili:

Sorry, a bit late :/

You probably already figured it out yourself, but i hate these kind of loose ends.

Quote:
BSzili wrote:
So it'll only enter subdirectories which match the AHX.#? wildcard. This is what you've been saying, but I had hard time grasping it


And this is how you can incorporate the solution to that problem into the initial routine you pointed to (at least i got some desired results, not heavily tested: should work 100% in theory):
Program RecurseFilematch;

{
$MODE OBJFPC}{$H+}

uses
  aros_exec
,
  
aros_dos,
  
SysUtils;



Procedure FileSearchAROS(const pathname, FileMask: string; const DoRecursive: boolean);
{
  
Routine based on thomas-rapps post -> 
   
http://eab.abime.net/showpost?p=660659&postcount=5
  
FileSearch routine that can search directories recursive (no restrictions) and match
  a given filepattern
. The pattern is not applied to the directory, only to the file.
  
This routine is not foolproof and definatly needs a bit more TLC.
  
Sorry for the ugly code.
}

var 
  
ap          : PAnchorPath;
  
error, 
  
level, 
  
i           : longint;

  
s,                        // We need a temp string because fpc does not have a ? operator
  
filename    : String;     // String to hold the filename (and only filename part)
  
filemaskTOK : pChar;      // C-String to hold the tokenized mask needed for AROS API Routine
  
isMatch     : Longbool;   // Temp boolean placeholder to hold the matchresult
begin
  ap 
:= AllocVec(sizeof(TAnchorPath) + 1024, MEMF_CLEAR);
  if (
ap <> nil) then
  begin
    ap
^.ap_BreakBits := SIGBREAKF_CTRL_C;
    
ap^.ap_StrLen    := 1024;  
  
end;
  
  
level := 0;

  
error := MatchFirst(pathname, ap);

  if (
error = 0) and (ap^.ap_Info.fib_DirEntryType >= 0)
    
then ap^.ap_Flags := ap^.ap_Flags or APF_DODIR;
  
  while (
error = 0) do
  
begin
    
if ((ap^.ap_Flags and APF_DIDDIR) <> 0) then
    begin
      
{ Leaving a directory entered below (APF_DODIR) }
      
dec(level);
      
ap^.ap_Flags := ap^.ap_Flags and not(APF_DIDDIR);    
    
end
    
else
    
begin
      
{
        
Soft linked objects are returned by the scanner
        but they need special treatments
; we are merely
        ignoring them here in order to keep this example
        simple
      
}
      if (
ap^.ap_Info.fib_DirEntryType <> ST_SOFTLINK) then
      begin
        
{ 
          
provide for some indentation 
        
}
        for 
i := 0 to pred(level) do write(' ');
        
        if (
ap^.ap_Info.fib_DirEntryType < 0) then
        begin
          s 
:= '';  { no ? operator: results in dumb code to mimic the behaviour }
          
          {
            
According to AutoDocs/FileInfoBlock struct, we can now
            be certain that we 
do not deal with a directory, but are
            dealing with an actual file
.
            
So if we can find a way to determine the name of the
            file then we could 
do nice things with it, such as 
            
emitting the name.
          }
          { 
get the name }
          
Filename := ap^.ap_Info.fib_FileName;
          { do 
something nice, and emit the filename }
          
writeln('filename = ',filename);
          
          {
            
Now we have a real filename (only) to work with. But 
            what should we 
do with it ? Is it even usefull ?
            
We know we need the filename to match the given 
            filemask
.
            
Is there perhaps a way to do this ? Lets try:                  
          }
          { 
allocate heapmem for pchar: fpc business. Size taken from AutoDocs }
          
FileMaskTOK := stralloc((Length(FileMask) * 2) + 2);
          { 
create a tokenized filemask with a trickery cast. Size taken from AutoDocs }
          
ParsePatternNoCase(pchar(FileMask), FileMaskTOK, (Length(FileMask) * 2) + 2);
          { 
match a pattern }
          
IsMatch := MatchPatternNoCase(FileMaskTOK, FileName);
          { 
check the result, if we match we emit the name, or you can do whatever with it }
          if 
IsMatch then writeln('It seems that the above printed filename matches the filemask o/');          
          { return 
allocated heapmem for pchar: fpc business }          
          
strdispose(FileMaskTOK);
        
end  
        
else s := ' (Dir)'; { no ? operator: results in dumb code to mimic the behaviour }
          
        
        
writeln(format('%s%s',[ap^.ap_Buf, s]));
        
        { If 
this is a directory, enter it }
        if ((
ap^.ap_Info.fib_DirEntryType >= 0) and DoRecursive) then
        begin
          ap
^.ap_Flags := (ap^.ap_Flags or APF_DODIR);
          
inc(level);
        
end;
        
        
      
end;
    
end;
    
error := MatchNext(ap);
  
  
  
end;
  
MatchEnd(ap);
  
FreeVec(ap);
end;



Begin
  WriteLn
('start');


  
FileSearchAROS('Ram:','#?.info', true);
  

  
Writeln('end');
End.


Which gives me the following output:

start
Ram
: (Dir)
 
Ram:Clipboards (Dir)
  
filename = 2
Ram
:Clipboards/2
 Ram
:ENV (Dir)
  
Ram:ENV/SYS (Dir)
   
filename = ahi.prefs
Ram
:ENV/SYS/ahi.prefs
   filename 
= poseidon.prefs
Ram
:ENV/SYS/poseidon.prefs
   filename 
= locale.prefs
Ram
:ENV/SYS/locale.prefs
   filename 
= input.prefs
Ram
:ENV/SYS/input.prefs
   filename 
= theme.var
Ram:ENV/SYS/theme.var
   
filename = screenmode.prefs
Ram
:ENV/SYS/screenmode.prefs
   filename 
= icontrol.prefs
Ram
:ENV/SYS/icontrol.prefs
   filename 
= pointer.prefs
Ram
:ENV/SYS/pointer.prefs
   filename 
= nv_location
Ram
:ENV/SYS/nv_location
   filename 
= font.prefs
Ram
:ENV/SYS/font.prefs
   filename 
= def_winurl.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_winurl.info
   filename 
= def_Zune.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Zune.info
   filename 
= def_XCF.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_XCF.info
   filename 
= def_UserHome.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_UserHome.info
   filename 
= def_USB.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_USB.info
   filename 
= def_TrueType.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_TrueType.info
   filename 
= def_Trashcan.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Trashcan.info
   filename 
= def_Tool.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Tool.info
   filename 
= def_Text.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Text.info
   filename 
= def_Spreadsheet.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Spreadsheet.info
   filename 
= def_Sound.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Sound.info
   filename 
= def_SFS.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_SFS.info
   filename 
= def_ReadMe.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_ReadMe.info
   filename 
= def_REXX.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_REXX.info
   filename 
= def_RAM.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_RAM.info
   filename 
= def_RAD.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_RAD.info
   filename 
= def_Python.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Python.info
   filename 
= def_Project.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Project.info
   filename 
= def_Printer.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Printer.info
   filename 
= def_Presentation.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Presentation.info
   filename 
= def_Pref.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Pref.info
   filename 
= def_Postscript.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Postscript.info
   filename 
= def_Picture.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Picture.info
   filename 
= def_Patch.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Patch.info
   filename 
= def_PLS.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_PLS.info
   filename 
= def_PDF.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_PDF.info
   filename 
= def_Otag.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Otag.info
   filename 
= def_NetworkHost.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_NetworkHost.info
   filename 
= def_NDOSharddisk.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_NDOSharddisk.info
   filename 
= def_NDOSdisk.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_NDOSdisk.info
   filename 
= def_NDOSCDROM.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_NDOSCDROM.info
   filename 
= def_Music.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Music.info
   filename 
= def_Movie.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Movie.info
   filename 
= def_MSI.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_MSI.info
   filename 
= def_MSD.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_MSD.info
   filename 
= def_MP3ID3.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_MP3ID3.info
   filename 
= def_MP3.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_MP3.info
   filename 
= def_M3U.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_M3U.info
   filename 
= def_Lua.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Lua.info
   filename 
= def_Legal.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Legal.info
   filename 
= def_Keymap.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Keymap.info
   filename 
= def_Installer.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Installer.info
   filename 
= def_Home.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Home.info
   filename 
= def_Harddisk.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Harddisk.info
   filename 
= def_HTML.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_HTML.info
   filename 
= def_Font.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Font.info
   filename 
= def_FLAC.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_FLAC.info
   filename 
= def_FAT.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_FAT.info
   filename 
= def_Drawer.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Drawer.info
   filename 
= def_Document.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Document.info
   filename 
= def_Disk_hd.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Disk_hd.info
   filename 
= def_Disk.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Disk.info
   filename 
= def_DataType.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_DataType.info
   filename 
= def_DVD.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_DVD.info
   filename 
= def_DT64.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_DT64.info
   filename 
= def_Country.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Country.info
   filename 
= def_Catalog.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Catalog.info
   filename 
= def_CSS.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_CSS.info
   filename 
= def_CDXL.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_CDXL.info
   filename 
= def_CDROM.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_CDROM.info
   filename 
= def_Busyharddisk.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Busyharddisk.info
   filename 
= def_Busydisk.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Busydisk.info
   filename 
= def_BusyCDROM.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_BusyCDROM.info
   filename 
= def_Authors.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Authors.info
   filename 
= def_AudioMode.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_AudioMode.info
   filename 
= def_Archive.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_Archive.info
   filename 
= def_AmiLua.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_AmiLua.info
   filename 
= def_ADF.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_ADF.info
   filename 
= def_A68K.info
It seems that the above printed filename matches the filemask o
/
Ram:ENV/SYS/def_A68K.info
   Ram
:ENV/SYS/Wanderer (Dir)
    
filename = global.prefs
Ram
:ENV/SYS/Wanderer/global.prefs
    filename 
= toolbar.prefs
Ram
:ENV/SYS/Wanderer/toolbar.prefs
    filename 
= statusbar.prefs
Ram
:ENV/SYS/Wanderer/statusbar.prefs
   Ram
:ENV/SYS/Packages (Dir)
    
filename = DOpus
Ram
:ENV/SYS/Packages/DOpus
    filename 
= DOpus.bak
Ram
:ENV/SYS/Packages/DOpus.bak
    filename 
= wget
Ram
:ENV/SYS/Packages/wget
    filename 
= MCC_Urltext
Ram
:ENV/SYS/Packages/MCC_Urltext
    filename 
= MCC_Toolbar
Ram
:ENV/SYS/Packages/MCC_Toolbar
    filename 
= MCC_TheBar
Ram
:ENV/SYS/Packages/MCC_TheBar
    filename 
= MCC_NList
Ram
:ENV/SYS/Packages/MCC_NList
    filename 
= MCC_MailText
Ram
:ENV/SYS/Packages/MCC_MailText
    filename 
= Lua
Ram
:ENV/SYS/Packages/Lua
    filename 
= Feelin
Ram
:ENV/SYS/Packages/Feelin
    filename 
= Developer
Ram
:ENV/SYS/Packages/Developer
    filename 
= BGUI
Ram
:ENV/SYS/Packages/BGUI
    filename 
= AROSTCP
Ram
:ENV/SYS/Packages/AROSTCP
  filename 
= Annotate.xml
Ram
:ENV/Annotate.xml
  filename 
= Annotate.autoupdate
Ram
:ENV/Annotate.autoupdate
  filename 
= snoopy.prefs
Ram
:ENV/snoopy.prefs
  filename 
= MobileBroadband.prefs
Ram
:ENV/MobileBroadband.prefs
  filename 
= DEVELPATH
Ram
:ENV/DEVELPATH
  filename 
= EXTRASPATH
Ram
:ENV/EXTRASPATH
  filename 
= wgetcfg
Ram
:ENV/wgetcfg
  filename 
= w4096
Ram
:ENV/w4096
  filename 
= hdtoolbox.prefs
Ram
:ENV/hdtoolbox.prefs
  filename 
= hdaudio.config
Ram
:ENV/hdaudio.config
  filename 
= h4096
Ram
:ENV/h4096
  filename 
= gs860
Ram
:ENV/gs860
  Ram
:ENV/Zune (Dir)
   
filename = TRIDENT.cfg
Ram
:ENV/Zune/TRIDENT.cfg
   filename 
= global.prefs
Ram
:ENV/Zune/global.prefs
   filename 
= YAM.cfg
Ram
:ENV/Zune/YAM.cfg
   filename 
= PublicScreens.iff
Ram
:ENV/Zune/PublicScreens.iff
   filename 
= SNAKEE.1.cfg
Ram
:ENV/Zune/SNAKEE.1.cfg
   filename 
= OWB.1.cfg
Ram
:ENV/Zune/OWB.1.cfg
   filename 
= PSI.1.prefs
Ram
:ENV/Zune/PSI.1.prefs
   filename 
= UNNAMED.1.prefs
Ram
:ENV/Zune/UNNAMED.1.prefs
   filename 
= OWB.1.prefs
Ram
:ENV/Zune/OWB.1.prefs
  filename 
= ZoomIT.prefs
Ram
:ENV/ZoomIT.prefs
  filename 
= Wireless.prefs
Ram
:ENV/Wireless.prefs
  filename 
= PortablE_Installation
Ram
:ENV/PortablE_Installation
  Ram
:ENV/MysticView (Dir)
   
filename = Paths
Ram
:ENV/MysticView/Paths
  filename 
= MUIbase.prefs
Ram
:ENV/MUIbase.prefs
  filename 
= MUIBuilder.env
Ram
:ENV/MUIBuilder.env
  Ram
:ENV/Icaros (Dir)
   
filename = amistart-conf
Ram
:ENV/Icaros/amistart-conf
   filename 
= amistart
Ram
:ENV/Icaros/amistart
   filename 
= sharing
Ram
:ENV/Icaros/sharing
   filename 
= fkey
Ram
:ENV/Icaros/fkey
   filename 
= opaque
Ram
:ENV/Icaros/opaque
   filename 
= amigavm
Ram
:ENV/Icaros/amigavm
   filename 
= 1sttime
Ram
:ENV/Icaros/1sttime
   filename 
= MYPATH
Ram
:ENV/Icaros/MYPATH
   filename 
= vnc
Ram
:ENV/Icaros/vnc
   filename 
= usb
Ram
:ENV/Icaros/usb
   filename 
= liveupmode
Ram
:ENV/Icaros/liveupmode
   filename 
= awin
Ram
:ENV/Icaros/awin
   filename 
= 2ndtime
Ram
:ENV/Icaros/2ndtime
  Ram
:ENV/Feelin (Dir)
   
filename = PreferenceEditor.obj
Ram
:ENV/Feelin/PreferenceEditor.obj
   filename 
= demo_SignalHandler.obj
Ram
:ENV/Feelin/demo_SignalHandler.obj
   filename 
= demo_Class2.obj
Ram
:ENV/Feelin/demo_Class2.obj
   filename 
= demo_Class1.obj
Ram
:ENV/Feelin/demo_Class1.obj
   filename 
= _Global_.gui
Ram
:ENV/Feelin/_Global_.gui
  filename 
= CURRENT_INSTALL
Ram
:ENV/CURRENT_INSTALL
  filename 
= AnnotateSyntax.xml
Ram
:ENV/AnnotateSyntax.xml
  Ram
:ENV/AROSTCP (Dir)
   
filename = MobileAutorun
Ram
:ENV/AROSTCP/MobileAutorun
   Ram
:ENV/AROSTCP/db (Dir)
    
filename = static-routes
Ram
:ENV/AROSTCP/db/static-routes
    filename 
= services
Ram
:ENV/AROSTCP/db/services
    filename 
= protocols
Ram
:ENV/AROSTCP/db/protocols
    filename 
= networks
Ram
:ENV/AROSTCP/db/networks
    filename 
= netdb-myhost
Ram
:ENV/AROSTCP/db/netdb-myhost
    filename 
= netdb
Ram
:ENV/AROSTCP/db/netdb
    filename 
= interfaces
Ram
:ENV/AROSTCP/db/interfaces
    filename 
= inet.access
Ram
:ENV/AROSTCP/db/inet.access
    filename 
= hosts
Ram
:ENV/AROSTCP/db/hosts
    filename 
= general.config
Ram
:ENV/AROSTCP/db/general.config
    filename 
= dhclient.lease
Ram
:ENV/AROSTCP/db/dhclient.lease
   filename 
= WirelessAutoRun
Ram
:ENV/AROSTCP/WirelessAutoRun
   filename 
= Config
Ram
:ENV/AROSTCP/Config
   filename 
= AutoRun
Ram
:ENV/AROSTCP/AutoRun
  filename 
= ABI
Ram
:ENV/ABI
  filename 
= Language
Ram
:ENV/Language
  filename 
= HOSTNAME
Ram
:ENV/HOSTNAME
 Ram
:T (Dir)
  
filename = dhclient.pid
Ram
:T/dhclient.pid
  filename 
= Tmp111273143820341
Ram
:T/Tmp111273143820341
end


Regards,

PS: just realized, the ParsePatternNoCase should ofcourse be able to be placed out of while loop to gain more speed.

Posted on: 2012/11/9 8:42

Edited by magorium on 2012/11/10 9:17:40
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Directory listing with wildcards
#13
Home away from home
Home away from home


See User information
I'm not completely sure what the linked source code should do... but I know C:List will not do what you want. You might need something more like "C:Search FILE ALL PATTERN". It might be worthwhile looking at the source for Search.

Posted on: 2012/11/4 18:06
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Directory listing with wildcards
#12
Home away from home
Home away from home


See User information
/me nodds franticly and gives bszili a high five

That was indeed what i was trying to say. Just to make sure i _suspect_ that is what is happening. I do not seem to remember how this was done in the old days and if it could be solved in one go (matchrun) by changing the flags.

From the things i've seen sofar the code you posted does a recursive dir perfectly (#?). Now it only needs a filematch.

One of the exmaples even does not use the match-routines but uses the file equivalents and checks them manually, which is ofcourse also a (valid) solution.

Sorry to have you confused, i thought it was clear enough from my first explanation. Obviously i need to work on my skills

Just glad you figured it out. Even if that solution from the code you posted could be turned into a working version (doing it one match-run) you now at least know what the difference is/would be

regards,

ps: Because i suspected it perhaps not being so easy i haven't got around it to turn the fpc code into using aros functions only. If i would have done i would have a clear solution/answer for you, which i don't have now :(

Posted on: 2012/11/4 14:09
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Directory listing with wildcards
#11
Home away from home
Home away from home


See User information
I saw those, but it's still not entirely clear. I only learn from examples
Since I figured out the source of the confusion. What I expected from recursively matching for AHX.#? was:
Quote:

Match AHX.#? for files in the current directory and every subdirectory.

But what is really does is this:
Quote:

Match AHX.#? for files and directories in the current directory and every subdirectory.

So it'll only enter subdirectories which match the AHX.#? wildcard. This is what you've been saying, but I had hard time grasping it

Posted on: 2012/11/4 13:45
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Directory listing with wildcards
#10
Home away from home
Home away from home


See User information
@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 12:36

Edited by magorium on 2012/11/4 13:41:45
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Directory listing with wildcards
#9
Home away from home
Home away from home


See User information
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 12:24
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Directory listing with wildcards
#8
Home away from home
Home away from home


See User information
In an attempt to have the correct communicationprotocol

in pseusocode this is what i use:
procedure filesearch (pathname, filename: string; Recursive: boolean);
Var
  
SR: TSearchRec;
  
path : string;

begin
  
{ first run, we take files from current pathname }
  
path := makesurepathdelimisthere(pathname);
  if 
findfirst(path + filename, isafileonly, SR) then
  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 run, directories only }
  if 
findfirst(path + '*', isadirectoy, SR) = 0 then
  repeat
    
If (SR.Attribute = directory and directory only) then filesearch (path + SR.name, Filename, True);
  
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 9:52
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Directory listing with wildcards
#7
Home away from home
Home away from home


See User information
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 9:20
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Directory listing with wildcards
#6
Home away from home
Home away from home


See User information
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 9:04
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 




(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.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4462
2 nikolaos
nikolaos
4206
3 magorium
magorium
4095
4 phoenixkonsole
phoenixkonsole
3942
5 deadwood
deadwood
2917
6 ncafferkey
ncafferkey
2810
7 mazze
mazze
2222
8 Kalamatee
Kalamatee
2212
9 clusteruk
clusteruk
2114
Powered by XOOPS © 2001-2025 The XOOPS Project