home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
On Disk Monthly 62
/
odm62.zip
/
GDSOURCE.EXE
/
SD.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-10-14
|
3KB
|
120 lines
{$A-,B-,D+,E+,F-,G-,I+,L+,N-,O-,R-,S+,V-,X-}
{$M 16384,0,655360}
program savedirectory;
USES dos, crt;
CONST DataFilename = 'C:\PATHS.DAT';
MaximumPaths = 840;
LastPath = 'ZZZZ\ZZZZ\ZZZZ\ZZZZ\ZZZZ\ZZZZ\ZZZZ';
VAR T : text;
DTA : searchrec;
NumPaths : integer;
Paths : array [1..MaximumPaths] of DirStr;
DirGotten,
CurrPath,
SaveStr : DirStr;
I : integer;
FUNCTION ComparePaths(Path1, Path2: string): boolean;
VAR PartialPath1,
PartialPath2: string;
FUNCTION SlashPos(PathCheck:string):byte;
VAR Count: byte;
BEGIN
Count := Pos('\', PathCheck);
IF Count = 0 THEN
Count := Length(PathCheck)+1;
SlashPos := Count;
END;
FUNCTION ParsePath(PathCheck:string): string;
VAR TempStr: string;
BEGIN
TempStr := copy(PathCheck, 1, SlashPos(PathCheck));
IF TempStr[Length(TempStr)] = '\' THEN
Dec(TempStr[0]);
ParsePath := TempStr;
END;
BEGIN
PartialPath1 := ParsePath(Path1);
PartialPath2 := ParsePath(Path2);
WHILE (PartialPath1 = PartialPath2) AND (PartialPath1<>'') DO
BEGIN
Delete(Path1, 1, SlashPos(Path1));
Delete(Path2, 1, SlashPos(Path2));
PartialPath1 := ParsePath(Path1);
PartialPath2 := ParsePath(Path2);
END;
ComparePaths := (PartialPath1 >= PartialPath2);
END;
BEGIN
WriteLn('SAVE DIRECTORY Version 1.00 by George Leritte');
WriteLn('Copyright (c) 1991, Softdisk, Inc.');
Write(' ');
CurrPath := Fexpand('');
IF Length(CurrPath) > 3 THEN
Dec(CurrPath[0]);
SaveStr := CurrPath;
FindFirst(DataFilename, 32, DTA);
IF DosError <> 0 THEN
BEGIN
Assign(T, DataFilename);
Rewrite(T);
Close(T);
END;
DirGotten := CurrPath;
Assign(T, DataFilename);
Reset(T);
NumPaths := 0;
WHILE NOT Eof(T) AND (NumPaths<MaximumPaths) DO
BEGIN
Inc(NumPaths);
ReadLn(T, Paths[NumPaths]);
IF ComparePaths(CurrPath, Paths[NumPaths]) THEN
BEGIN
IF CurrPath = Paths[NumPaths] THEN
BEGIN
CurrPath := LastPath;
END;
END
ELSE
BEGIN
IF CurrPath <> '' THEN
BEGIN
Paths[NumPaths+1] := Paths[NumPaths];
Paths[NumPaths] := CurrPath;
Inc(NumPaths);
SaveStr := '';
CurrPath := '';
END;
END;
END;
Close(T);
IF CurrPath <> LastPath THEN
BEGIN
IF NumPaths >= MaximumPaths THEN
WriteLn('Too many paths in file.')
ELSE
BEGIN
IF SaveStr <> '' THEN
BEGIN
Inc(NumPaths);
Paths[NumPaths] := CurrPath;
END;
Assign(T, DataFilename);
Rewrite(T);
FOR I := 1 TO NumPaths DO
WriteLn(T, Paths[I]);
Close(T);
WriteLn('Directory '+DirGotten+' saved.');
END;
END
ELSE
WriteLn('Directory '+DirGotten+' already saved.');
END.