Directory recursion - help! 
Author Message
 Directory recursion - help!

Can anybody provide me with a routine that will recurse directories in a
manner similar to PKZip?  I have Turbo Pascal 6.0, but a version for any
compiler would be gratefully accepted!

Andrew Kressman



Wed, 18 Jun 1902 08:00:00 GMT  
 Directory recursion - help!




Quote:
>Can anybody provide me with a routine that will recurse directories in a
>manner similar to PKZip?  I have Turbo Pascal 6.0, but a version for any
>compiler would be gratefully accepted!

>Andrew Kressman


Help yourself from Web URL:
        http://www.merlyn.demon.co.uk/programs/listdirs.pas

--

  Web URL: http://www.merlyn.demon.co.uk/ - FAQqish topics, acronyms and links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)



Wed, 18 Jun 1902 08:00:00 GMT  
 Directory recursion - help!

This is a multi-part message in MIME format.
--------------04762D351BEE08C79215D8E0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Quote:

> Can anybody provide me with a routine that will recurse directories in a
> manner similar to PKZip?  I have Turbo Pascal 6.0, but a version for any
> compiler would be gratefully accepted!

This in one of my old [way old] units. Look at it and you should be able
to get the idea for recursing dirs.

--
AIBrain Home Page -"Artificially Intelligent Brain"
http://www.geocities.com/CapeCanaveral/Lab/7677/index.html


--------------04762D351BEE08C79215D8E0
Content-Type: text/plain; charset=us-ascii; name="Indexer.pas"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Indexer.pas"

Unit Indexer;
InterFace

Procedure BuildAllDirList;
Function FindFile(S:String):String;

Implementation

Uses StrG,Crt,Files,CommonVars,Dos,MiscStringUnit;

Procedure BuildAllDirList;
Var C:Char;

Procedure BuildDirList(D:Char);
Var F:File;

Procedure ScanSub(T:String);
Var Dir:SearchRec;
Begin
        {$I-}
        ChDir(T);
        {$I+}
        If IOResult=0 Then
Begin
        If T[Length(T)]<>'\' Then T:=T+'\';

        FindFirst('*.*',AnyFile,Dir);           {may no change dir? just add path}
        While DosError=0 Do                             {to this find function?}
     Begin
                If ((Dir.Attr And Directory)=Directory) And ((Dir.Name<>'.') And (Dir.Name<>'..')) Then
          Begin
                        ScanSub(ConCat(T,Dir.Name));
          End;
                FindNext(Dir);
     End;
        If Length(T)>3 Then ChDir('..');
End;
End;

Begin
        Assign(F,DirListFile);
        ReSet(F,1);
        Seek(F,FileSize(F));
     {$I-\}
        ChDir(ConCat(D,':'));
     {$I+}
     If IOResult=0 Then
     Begin
                WriteLn(ConCat('Scanning drive ',D));
                ScanSub(ConCat(D,':','\'));
          GotoXy(1,WhereY-1);
          ClrEol;
     End;
        Close(F);
End;

Begin
        BrandNewFile(DirListFile);
        For C:='C' To 'Z' Do BuildDirList(C);
End;

Function FindFile(S:String):String;
Var F:File;
Var T:String;
Var Dir:SearchRec;
Var Result:String;
Var Found:Boolean;
Begin
        Assign(F,DirListFile);
        Reset(F,1);
        Found:=No;
        Result:=Nill;
        Repeat

                FindFirst(ConCat(T,S),Archive,Dir);
                If DosError=0 Then
                Begin
                        Result:=FExpand(FDirString(T)+Dir.Name);
                        Found:=Yes;
                End;
        Until Eof(F) Or Found;
        Close(F);
        FindFile:=Result;
End;

End.
--------------04762D351BEE08C79215D8E0--



Wed, 18 Jun 1902 08:00:00 GMT  
 Directory recursion - help!

Quote:


>> Can anybody provide me with a routine that will recurse directories in a
>> manner similar to PKZip?  I have Turbo Pascal 6.0, but a version for any
>> compiler would be gratefully accepted!
> This in one of my old [way old] units. Look at it and you should be able
> to get the idea for recursing dirs.

/snip/

Ooops, I guess I should have cleaned it up before I posted. Sorry.

--
AIBrain Home Page -"Artificially Intelligent Brain"
http://www.geocities.com/CapeCanaveral/Lab/7677/index.html




Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. recursion help

2. recursion(help)

3. Help requested understanding recursion.

4. Recursion help

5. Help!! Recursion Problem

6. Need Help on Recursion.

7. help with recursion

8. Need help with recursions

9. Help---->Linked list and recursion

10. How Copy 1 Directory with Sub Directory

11. File or directory does not exist error...help

12. Directory Is Busy Error, Please Help.

 

 
Powered by phpBB® Forum Software