home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
PASCAL
/
FASTDIR.ZIP
/
FASTDIR.DOC
next >
Wrap
Text File
|
1993-06-15
|
4KB
|
118 lines
WHAT IT DOES
------------
FASTDIR is a PASCAL program that will search directory paths and return a
linked list of all files that match the search critera. Additionally, it
can handle ARJ,ZIP,LZH,ARC and PAK archive files as if they too were
directories on your disk.
The search MASK can contain wildcards and multiple extensions. Each record
in the list is made up as follows :
DirPtr = ^DirRec;
DirRec = RECORD
fType : FILETYPES; { see filetypes }
Attr : WORD; { DOS file Attribute }
Time : LONGINT; { DOS file date/time }
PSize, { packed size if in archive }
Size : LONGINT; { orig size or DOS file size }
Method, { archive method if in archive }
Name : STRING [12]; { file name }
Path : PathStr; { file path }
Tag : BOOLEAN; { marked ??? }
Next, { next file }
Prev : DirPtr; { prev file }
END;
We then create a structured RECORD or list containing any number (up to
MAXDIRSIZE) of DirRec. Each of our DirRec's is pointed to by a DirPtr as
they are added to the HEAP. Each record takes approximatly 113 Bytes of
memory.
DirList = RECORD
Root,
Last,
Current : DirPtr; { Points to Root,Last,Current items }
Path : PathStr; { Dir Path Or Archive Name }
Mask : PathStr; { Command Line or params }
ArcType : FILETYPES; { DIR or Type of Archive }
Recurse : BOOLEAN; { Include SUBS Too }
Count, { file in this list }
Tagged : INTEGER; { tagged count }
Space, { space used by all files }
TSpace : LONGINT; { space used by tagged files }
Less : LessFunc; { Sort function }
END;
To create and use a list, we would declare a VAR in our program :
VAR
Sample : DirList;
Technically, we could have several lists at once, memory permitting. Each
one would have its own path, mask and could be handled independently.
HOW IT WORKS
------------
The process of searching a disk is really very simple. Essentially, the
process goes like this :
1. Declare a VAR for our list.
VAR
Sample : DirList;
2. Initialize our List. This is ABSOLUTELY necessary as we MUST initialize
the NEXT/PREV pointers to NIL.
InitializeDir(Sample);
3. Set the PATH, MASK and RECURSE values.
Sample.Path := FExpand('\');
Sample.Mask := '*.ZIP *.ARJ';
{ multiple extensions OK !! }
Sample.Recurse := TRUE;
4. Find all files matching.
FindFiles(Sample,Sample.Path);
OR
GetFiles(Sample,AnyArcOrDirName,Mask,SortFormat);
Here, GETFILES will decide whether ANYARCORDIRNAME is a Directory OR
Archive and return all of the file members in SAMPLE. SortFormat is any
one of the SORT functions avaiable. See FASTDIR.PAS for these.
5. Traverse our list and do something with the files.
Sample.Current := Sample.Root;
WHILE Sample.Current <> NIL DO
BEGIN
{ Call any procedure that you want to do something }
HandleTheFile(Sample.Current);
Sample.Current := Sample.Current^.Next;
END;
6. Clean up and dispose of memory used.
DestroyDirList(Sample);
That is all there is to it. I hope that you find it useful.
Gayle Davis
GDSOFT