![]() |
|
![]() |
CONST
DriveLength = 3;
DirectoryLength = 150;
NameLength = 75;
ExtensionLength = 15;
VolumeLabelLength = 12;
FullLength = DriveLength + DirectoryLength + NameLength + ExtensionLength;
TYPE
DriveType = ARRAY [0 .. DriveLength] OF CHAR;
DirectoryType = ARRAY [0 .. DirectoryLength] OF CHAR;
NameType = ARRAY [0 .. NameLength] OF CHAR;
ExtensionType = ARRAY [0 .. ExtensionLength] OF CHAR;
FullType = ARRAY [0 .. FullLength] OF CHAR;
VolumeLabelType = ARRAY [0 .. VolumeLabelLength] OF CHAR;
DiskRecordType = RECORD
Full : FullType;
Drive : DriveType;
Directory : DirectoryType;
FileName : NameType;
Extension : ExtensionType;
END;
QueryType = (AndQuery,
OrQuery);
PreDeleteProcType = PROCEDURE (CONST ARRAY OF CHAR,
VAR BOOLEAN);
PostDeleteProcType = PROCEDURE (CONST ARRAY OF CHAR,
VAR Files.FileState);
PostLocateProcType = PROCEDURE (CONST DiskRecordType,
VAR BOOLEAN);
DiskRequestProcType = PROCEDURE (CONST CARDINAL,
VAR BOOLEAN);
FileBackupProcType = PROCEDURE (CONST ARRAY OF CHAR,
VAR BOOLEAN);
FileRestoreProcType = PROCEDURE (CONST ARRAY OF CHAR,
VAR BOOLEAN);
DirectoryProcType = PROCEDURE (CONST ARRAY OF CHAR,
VAR BOOLEAN);
PROCEDURE DriveValid
(CONST Drive : ARRAY OF CHAR) : BOOLEAN;
(**
DriveValid - Check IF a drive is valid.
This procedure checks a drive to see IF it is IN the available drive
list for the current machine.
CALLING SEQUENCE -
Valid := DriveValid ("T:");
ENTRY -
Drive : DriveType
The drive to check
EXIT -
BOOLEAN
TRUE = Drive is valid for this machine, FALSE = Drive is NOT valid
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestDV;
BEGIN
IF DriveValid ("T:") THEN
Terminal.WriteString ("DRIVE T IS ACCESSABLE");
Terminal.WriteLn;
ELSE
Terminal.WriteString ("DRIVE T IS NOT ACCESSIBLE");
Terminal.WriteLn;
END;
END TestDV;
*)
PROCEDURE DriveReady
(CONST Drive : ARRAY OF CHAR) : BOOLEAN;
(**
DriveReady - Check IF a drive is ready.
This procedure checks a drive to see IF it is ready for reads.
CALLING SEQUENCE -
Ready := DriveReady ("C:");
ENTRY -
Drive : DriveType
The drive letter to check
EXIT -
BOOLEAN
TRUE = Drive is ready, FALSE = Drive is NOT ready
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestDR;
BEGIN
IF DriveReady ("A:") THEN
Terminal.WriteString ("DRIVE A IS READY");
Terminal.WriteLn;
ELSE
Terminal.WriteString ("DRIVE A IS NOT READY");
Terminal.WriteLn;
END;
END TestDR;
*)
PROCEDURE DriveIsWritable
(CONST Drive : ARRAY OF CHAR) : BOOLEAN;
(**
DriveIsWritable - Check IF a drive is ready for writing.
This procedure checks a drive to see IF it is ready for writes.
CALLING SEQUENCE -
Ready := DriveReady ("C:");
ENTRY -
Drive : DriveType
The drive letter to check
EXIT -
BOOLEAN
TRUE = Drive is ready, FALSE = Drive is NOT ready
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestDR;
BEGIN
IF DiskLib.DriveIsWritable ("A:") THEN
Terminal.WriteString ("DRIVE A IS READY");
Terminal.WriteLn;
ELSE
Terminal.WriteString ("DRIVE A IS NOT READY");
Terminal.WriteLn;
END;
END TestDR;
*)
PROCEDURE SetAttribute
(CONST FileName : ARRAY OF CHAR;
CONST Normal : BOOLEAN;
CONST ReadOnly : BOOLEAN;
CONST Archive : BOOLEAN;
CONST SystemAttrib : BOOLEAN;
CONST Hidden : BOOLEAN);
(**
SetAttribute - SET attribute on file (s).
This procedure sets the attribute of a file OR files. The attributes are
Read-only, Archive, SystemAttrib AND Hidden. Wild cards may be used.
CALLING SEQUENCE -
SetAttribute (FileName);
ENTRY -
FileName : ARRAY OF CHAR
The filename (s) to verify - may use DOS wild cards AND valid path
ReadOnly : BOOLEAN
TRUE = SET ReadOnly attribute on, FALSE = SET ReadOnly attribute off.
Archive : BOOLEAN
TRUE = SET Archive attribute on, FALSE = SET Archive attribute off.
SystemAttrib : BOOLEAN
TRUE = SET System attribute on, FALSE = SET System attribute off.
Hidden : BOOLEAN
TRUE = SET Hidden attribute on, FALSE = SET Hidden attribute off.
EXIT -
None
N/A
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestSA;
BEGIN
SetAttribute ("*.DAT", FALSE,False, FALSE,True);
END TestSA;
*)
PROCEDURE DeleteFiles
(CONST FileName : ARRAY OF CHAR;
CONST PreDeleteProc : PreDeleteProcType;
CONST PostDeleteProc : PostDeleteProcType);
(**
DeleteFiles - Delete files.
This procedure deletes the specified files. Wild cards AND paths are
allowed. The DeleteFiles PROCEDURE is instantiated IMPORT two user-supplied
procedures a PreDelete PROCEDURE AND a PostDelete procedure. The
PreDelete PROCEDURE is passed the name OF each file found to be deleted AND
returns a variable indicating whether the file should be deleted. The
PostDelete PROCEDURE passes the name OF the file that was deleted AND the
state OF the deletion. These procedures have the following format:
PROCEDURE PreDelete
(filename : IN ARRAY OF CHAR;
deleteOK : IN out BOOLEAN);
PROCEDURE PostDelete
(filename : IN ARRAY OF CHAR;
deleteState : IN out Files.FileState);
This procedure will only delete 'ordinary' files. System, hidden, volume,
AND directory files will NOT be deleted.
CALLING SEQUENCE -
DiskLib.DeleteFiles (FileName, PreDelete, PostDelete);
ENTRY -
FileName : ARRAY OF CHAR
The filename (s) to delete - may use DOS wild cards AND valid path
EXIT -
None
N/A
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
IMPORT Files;
PROCEDURE TestDeleteFiles;
FileName : string[0..40) := (others : ' ');
ch : CHAR := ' ';
PROCEDURE MyPreDelete
(fileName : IN ARRAY OF CHAR;
deleteOK : IN out BOOLEAN);
BEGIN
Terminal.WriteString ("ok to delete ? (Y/N) File = " & FileName);
Terminal.ReadChar (ch);
Terminal.WriteLn;
IF ch = 'Y' OR ELSE ch = 'y' THEN
deleteOK := TRUE;
ELSE
deleteOK := FALSE;
END;
END MyPreDelete;
PROCEDURE MyPostDelete
(fileName : IN ARRAY OF CHAR;
deleteState : IN out Files.FileState);
BEGIN
IF deleteState = Files.ok THEN
Terminal.WriteString ("File deleted : File = " & FileName);
Terminal.WriteLn;
ELSE
Terminal.WriteString ("File NOT deleted, error = " & Files.FileState'image (deletestate) & " File = " & FileName);
Terminal.WriteLn;
END;
END MyPostDelete;
PROCEDURE MyDelete is new DiskLib.DeleteFiles
(MyPreDelete,MyPostDelete);
BEGIN
Terminal.WriteLn;
Terminal.WriteLn;
Terminal.WriteString ("Enter FileName to delete :");
Terminal.ReadString (FileName);
Terminal.WriteLn;
MyDelete (FileName);
END TestDeleteFiles;
*)
PROCEDURE AvailableDiskSpace
(CONST Drive : ARRAY OF CHAR) : REAL;
(**
AvailableDiskSpace - Check the amount OF available disk space.
This procedure returns total disk unused disk space for the given drive.
Available space is returned IN bytes. IF there is an error getting the
available disk space THEN -1.0 will be returned.
CALLING SEQUENCE -
space := DiskLib.AvailableDiskSpace ("C:");
ENTRY -
Drive : DriveType
The drive letter to check
EXIT -
ModSys.SLongFloat
the amount OF disk space IN bytes (note 123 bytes = 123.0 bytes)
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
IMPORT ConvertReal;
PROCEDURE TestAvailableDiskSpace;
space : longfloat := 0.0;
Str : string[0..20)[0] := ASCIIX.nul;
success : BOOLEAN = FALSE;
BEGIN
Terminal.WriteLn;
space := DiskLib.AvailableDiskSpace ("C:");
IF Space < 0.0 THEN
Terminal.WriteString ("INVALID DRIVE OR NOT READY OR OTHER ERROR");
Terminal.WriteLn;
ELSE
ConvertReal.LongFloatToStr (space,str,18,0,success);
Terminal.WriteString ("Available disk space on drive C: IS : " & str);
Terminal.WriteLn;
END;
END TestAvailableDiskSpace;
*)
PROCEDURE TotalDiskCapacity
(CONST Drive : ARRAY OF CHAR) : REAL;
(**
TotalDiskCapacity - Check the amount OF total disk space.
This procedure returns total disk capacity for the given drive. Total
space is returned IN bytes. IF there is an error getting the total disk
space THEN -1.0 will be returned.
CALLING SEQUENCE -
space := DiskLib.TotalDiskCapacity ("C:");
ENTRY -
Drive : DriveType
The drive letter to check
EXIT -
ModSys.SLongFloat
the amount OF disk capacity IN bytes (note 123 bytes = 123.0 bytes)
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
IMPORT ConvertReal;
PROCEDURE TestTotalDiskCapacity;
space : longfloat := 0.0;
Str : string[0..20)[0] := ASCIIX.nul;
success : BOOLEAN = FALSE;
BEGIN
Terminal.WriteLn;
space := DiskLib.TotalDiskCapacity ("C:");
IF Space < 0.0 THEN
Terminal.WriteString ("INVALID DRIVE OR NOT READY OR OTHER ERROR");
Terminal.WriteLn;
ELSE
ConvertReal.LongFloatToStr (space,str,18,0,success);
Terminal.WriteString ("Total disk capacity on drive C: IS : " & str);
Terminal.WriteLn;
END;
END TestTotalDiskCapacity;
*)
PROCEDURE MakeDirectory
(CONST Path : ARRAY OF CHAR;
VAR Success : BOOLEAN);
(**
MakeDirectory - Create a DOS directory.
This procedure will perform the same PROCEDURE as the MS-DOS MD command.
Refer to the MS-DOS documentation for further information.
CALLING SEQUENCE -
MakeDirectory ("\TEST\TEMP", Success);
ENTRY -
Path : ARRAY OF CHAR
The name of the directory to create. Do not include a trailing delimiter.
EXIT -
Success : BOOLEAN
TRUE - Operation worked.
FALSE - Operation failed.
EXAMPLE -
IMPORT DiskLib;
PROCEDURE TestMD;
BEGIN
DiskLib.MakeDirectory ("\TEST\TEMP", Success);
END TestMD;
*)
PROCEDURE RemoveDirectory
(CONST Path : ARRAY OF CHAR;
VAR Success : BOOLEAN);
(**
RemoveDirectory - Remove a DOS directory.
This procedure will perform the same PROCEDURE as the MS-DOS RD command.
Refer to the MS-DOS documentation for further information.
Note - You cannot remove a directory if it is the current directory for
the application. You must change the current directory to another
location first.
CALLING SEQUENCE -
RemoveDirectory ("\TEST\TEMP", Success);
ENTRY -
Path : ARRAY OF CHAR
The name of the directory to remove. Do not include a trailing delimiter.
EXIT -
Success : BOOLEAN
TRUE - Operation worked.
FALSE - Operation failed.
EXAMPLE -
IMPORT DiskLib;
PROCEDURE TestRD;
BEGIN
DiskLib.RemoveDirectory ("\TEST\TEMP", Success);
END TestRD;
*)
PROCEDURE ChangeDirectory
(CONST Path : ARRAY OF CHAR;
VAR Success : BOOLEAN);
(**
ChangeDirectory - Change to a directory.
This procedure will perform the same PROCEDURE as the MS-DOS CD command.
Refer to the MS-DOS documentation for further information.
CALLING SEQUENCE -
ChangeDirectory ("\TEST\TEMP", Success);
ENTRY -
Path : ARRAY OF CHAR
The name of the directory to move to. Do not include the trailing delimiter.
EXIT -
Success : BOOLEAN
TRUE - Operation worked.
FALSE - Operation failed.
EXAMPLE -
IMPORT DiskLib;
PROCEDURE TestCD;
BEGIN
DiskLib.ChangeDirectory ("\TEST\TEMP", Success);
END TestCD;
*)
PROCEDURE GetCurrentDirectory
(VAR Directory : ARRAY OF CHAR);
(**
GetCurrentDirectory - Get the current logged directory.
This procedure will return the current directory name.
CALLING SEQUENCE -
GetCurrentDirectory (MyDir);
EXIT -
Directory : DirectoryType
The name OF the current directory
EXAMPLE -
IMPORT DiskLib;
PROCEDURE TestGetDir;
MyDir : DiskLib.DirectoryType;
BEGIN
DiskLib.GetCurrentDirectory (MyDir);
END TestGetDir;
*)
PROCEDURE FindFirstMatch
(CONST Search : ARRAY OF CHAR;
CONST Normal : BOOLEAN;
CONST ReadOnly : BOOLEAN;
CONST Hidden : BOOLEAN;
CONST SystemAttrib : BOOLEAN;
CONST Volume : BOOLEAN;
CONST Directory : BOOLEAN;
CONST Archive : BOOLEAN;
VAR DiskRec : DiskRecordType;
VAR Success : BOOLEAN);
(**
FindFirstMatch - Perform a query to find first file and/or directory match.
This procedure will perform a query to find the name of a file and/or
directory that matches the parameters. The attributes of a match
are searched for using an and operation. For example let's take two
files like the following:
TEST1.FIL r
TEST2.FIL rh
TEST1.FIL has the read only attribute set. TEST2.FIL has both the read
only and the hidden attribute set. It we were to query using the
following parameters:
FindFirstMatch (Search : "TE*.*",
Normal : FALSE,
ReadOnly : TRUE,
Hidden : TRUE,
SystemAttrib : FALSE,
Volume : FALSE,
Directory : FALSE,
Archive : FALSE,
DiskRec : DiskRecord,
Success : Success);
we would get a hit on only the TEST2.FIL because we said that it must
have the read only AND the hidden attribute set. IF we did a query
with the following parameters:
FindFirstMatch (Search : "TE*.*",
Normal : FALSE,
ReadOnly : TRUE,
Hidden : FALSE,
SystemAttrib : FALSE,
Volume : FALSE,
Directory : FALSE,
Archive : FALSE,
DiskRec : DiskRecord,
Success : Success);
we would get a hit on TEST1.FIL. That is because it is the only one
with exactly the attributes that we requested.
CALLING SEQUENCE -
FindFirstMatch ("TE*.*", FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE,
DiskRecord, Success);
ENTRY -
Search : ARRAY OF CHAR
The name OF the files to look for (wild cards/directories allowed)
Normal : BOOLEAN
Look for the normal attribute
Readonly : BOOLEAN
Look for the read only attribute
Hidden : BOOLEAN
Look for the hidden attribute
SystemAttrib : BOOLEAN
Look for the system attribute
Volume : BOOLEAN
Look for the volume attribute
Directory : BOOLEAN
Look for the directory attribute
Archive : BOOLEAN
Look for the archive attribute
EXIT -
DiskRec : DiskRecordType
A record containing the data for the file which matched.
Success : BOOLEAN
BOOLEAN value for whether a match was found.
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestFF
Find a file IMPORT read only AND hidden attribute
BEGIN
DiskLib.FindFirstMatch (Search : "*.*",
Normal : FALSE,
ReadOnly : TRUE,
Hidden : TRUE,
SystemAttrib : FALSE,
Volume : FALSE,
Directory : FALSE,
Archive : FALSE,
DiskRec : DiskRecord,
Success : Success);
IF Success THEN
Terminal.WriteString ("Matching file: " &
DiskRecord.Full);
Terminal.WriteLn;
END;
END TestFF;
*)
PROCEDURE FindNextMatch
(VAR DiskRec : DiskRecordType;
VAR Success : BOOLEAN);
(**
FindNextMatch - Uses result OF FindFirstMatch to find next match.
This procedure will perform a query to find the name OF a file and/or
directory that matches the paramters originally given to FindFirstMatch.
CALLING SEQUENCE -
FindNextMatch (DiskRecord, Success);
ENTRY -
DiskRec : DiskRecordType
A record containing the data from the FindFirstMatch call.
Success : BOOLEAN
BOOLEAN value for whether a match was found.
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestFN
Find a file IMPORT read only AND hidden attribute
BEGIN
DiskLib.FindFirstMatch (Search : "*.*",
Normal : FALSE,
ReadOnly : TRUE,
Hidden : TRUE,
SystemAttrib : FALSE,
Volume : FALSE,
Directory : FALSE,
Archive : FALSE,
DiskRec : DiskRecord,
Success : Success);
IF Success THEN
WHILE Success LOOP
Terminal.WriteString ("Matching file: " &
DiskRecord.Full);
Terminal.WriteLn;
DiskLib.FindNextMatch (DiskRec : DiskRecord,
Success : Success);
END;
END;
END TestFN;
*)
PROCEDURE DiskQuery
(CONST Search : ARRAY OF CHAR;
CONST Normal : BOOLEAN;
CONST ReadOnly : BOOLEAN;
CONST Hidden : BOOLEAN;
CONST SystemAttrib : BOOLEAN;
CONST Volume : BOOLEAN;
CONST Directory : BOOLEAN;
CONST Archive : BOOLEAN;
CONST AttribType : QueryType;
CONST PostLocateProc : PostLocateProcType);
(**
DiskQuery - Perform a query to find files and/or directories.
This procedure will perform a query to find the name OF any files and/or
directories that match the parameters. The attributes OF matching files
may be searched for IN one OF two modes. for example let's take two
files like the following:
TEST1.FIL r
TEST2.FIL rh
TEST1.FIL has the read only attribute set. TEST2.FIL has both the read
only AND the hidden attribute set. It we were to query using the AND
mode IMPORT the following parameters:
DiskQuery (Search : "TE*.*",
Normal : FALSE,
ReadOnly : TRUE,
Hidden : TRUE,
SystemAttrib : FALSE,
Volume : FALSE,
Directory : FALSE,
Archive : FALSE,
AttribType : AndQuery);
we would get a hit on only the TEST2.FIL because we said that it must
have the read only AND the hidden attribute set. IF we did a query
IMPORT the following parameters:
DiskQuery (Search : "TE*.*",
Normal : FALSE,
ReadOnly : TRUE,
Hidden : TRUE,
SystemAttrib : FALSE,
Volume : FALSE,
Directory : FALSE,
Archive : FALSE,
AttribType : OrQuery);
we would gets hits on both TEST1.FIL AND TEST2.FIL. That is because we
we wanted to get files IMPORT the read only OR the hidden attribute set.
CALLING SEQUENCE -
DiskQuery ("TE*.*", FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE,
DiskLib.OrQuery);
ENTRY -
Search : ARRAY OF CHAR
The name OF the files to look for (wild cards/directories allowed)
Normal : BOOLEAN
Look for the normal attribute
Readonly : BOOLEAN
Look for the read only attribute
Hidden : BOOLEAN
Look for the hidden attribute
SystemAttrib : BOOLEAN
Look for the system attribute
Volume : BOOLEAN
Look for the volume attribute
Directory : BOOLEAN
Look for the directory attribute
Archive : BOOLEAN
Look for the archive attribute
AttribType : BOOLEAN
SET to show IF the attributes should be treated IN AND OR OR mode.
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestQ;
Find all files IMPORT read only OR hidden attribute
PROCEDURE PostLocateProc
(DiskRecord : IN DiskRecordType;
ContinueOn : IN out BOOLEAN);
MyQuery is new DiskLib.DiskQuery (PostLocateProc);
PROCEDURE PostLocateProc
(DiskRecord : IN DiskLib.DiskRecordType;
ContinueOn : IN out BOOLEAN);
BEGIN
Terminal.WriteString ("Matching file: " &
DiskRecord.Full);
Terminal.WriteLn;
ContinueOn := TRUE;
END PostLocateProc;
BEGIN
MyQuery (Search : "*.*",
Normal : FALSE,
ReadOnly : TRUE,
Hidden : TRUE,
SystemAttrib : FALSE,
Volume : FALSE,
Directory : FALSE,
Archive : FALSE,
AttribType : OrQuery);
END TestQ;
*)
PROCEDURE Backup
(CONST Source : ARRAY OF CHAR;
CONST DestDrive : ARRAY OF CHAR;
CONST DiskRequestProc : DiskRequestProcType;
CONST FileBackupProc : FileBackupProcType);
(**
Backup - Backup files across multiple diskettes.
This procedure will perform the same PROCEDURE as the MS-DOS 5.0 BACKUP
command. Files generated BY This procedure are fully compatible IMPORT
MS-DOS 5.0 backup files AND may be restored using the MS-DOS 5.0 REStoRE
command OR the DiskLib.Restore procedure. Refer to the MS-DOS 5.0
documentation for further information about the BACKUP command. This
PROCEDURE is instantiated IMPORT two procedures: DiskRequest AND FileBackup.
DiskRequest is called BY This procedure each time a disk change request
is processed. The disk NUMBER requested is passed IN AND the entire
backup may be aborted BY setting the continue flag to false. The
FileBackup PROCEDURE is called prior to a file being copied to the
destination drive. The filename is passed to the procedure. The
PROCEDURE may SET the continue flag to FALSE to abort the entire backup.
CALLING SEQUENCE -
MyBackup (Source, DestDrive);
ENTRY -
Source : ARRAY OF CHAR
The name OF the files to backup (wild cards/directories allowed)
DestDrive : DriveType
The destination drive identifier i.e. "B:"
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestBU;
InputStr : String[0..1);
PROCEDURE DiskRequestProc
(DiskNumber : IN ModSys.SNatural;
ContinueOn : IN out BOOLEAN);
PROCEDURE FileBackupProc
(FileName : IN FullType;
ContinueOn : IN out BOOLEAN);
MyBackup is new DiskLib.Backup (DiskRequestProc,FileBackupProc);
PROCEDURE DiskRequestProc
(DiskNumber : IN ModSys.SNatural;
ContinueOn : IN out BOOLEAN);
BEGIN
Terminal.WriteString ("Enter diskette # " &
ModSys.SNatural'image (DiskNumber) &
" AND press enter to continue");
Terminal.ReadString (InputStr);
Terminal.WriteLn;
ContinueOn := TRUE;
END DiskRequestProc;
PROCEDURE FileBackupProc
(FileName : IN FullType;
ContinueOn : IN out BOOLEAN);
BEGIN
Terminal.WriteString ("BACKING UP " & FileName);
Terminal.WriteLn;
ContinueOn := TRUE;
END FileBackupProc;
BEGIN
MyBackup ("*.*","B:");
END TestBU;
*)
PROCEDURE Restore
(CONST SourceDrive : ARRAY OF CHAR;
CONST Dest : ARRAY OF CHAR;
CONST DiskRequestProc : DiskRequestProcType;
CONST FileRestoreProc : FileRestoreProcType);
(**
Restore - Restore files from a backup (see DiskLib.Backup).
This procedure will perform the same PROCEDURE as the MS-DOS 5.0 REStoRE
command. Refer to the MS-DOS 5.0 documentation for further information
about the REStoRE command. This procedure is instantiated IMPORT two
procedures: DiskRequest AND FileRestore. DiskRequest is called BY this
PROCEDURE each time a disk change request is processed. The disk number
requested is passed IN AND the entire restore may be aborted BY setting
the continue flag to false. The FileRestore PROCEDURE is called prior to
a file being copied to the destination drive. The filename is passed to
the procedure. The PROCEDURE may SET the continue flag to FALSE to abort
the entire restore.
CALLING SEQUENCE -
MyRestore (SourceDrive, Dest);
ENTRY -
SourceDrive : DriveType
The source drive identifier i.e. "B:"
Dest : ARRAY OF CHAR
The name of the files to restore (wild cards/directories allowed)
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestRES;
InputStr : String[0..1);
PROCEDURE DiskRequestProc
(DiskNumber : IN ModSys.SNatural;
ContinueOn : IN out BOOLEAN);
PROCEDURE FileRestoreProc
(FileName : IN FullType;
ContinueOn : IN out BOOLEAN);
MyBackup is new DiskLib.Restore (DiskRequestProc,FileBackupProc);
PROCEDURE DiskRequestProc
(DiskNumber : IN ModSys.SNatural;
ContinueOn : IN out BOOLEAN);
BEGIN
Terminal.WriteString ("Enter diskette # " &
ModSys.SNatural'image (DiskNumber) &
" AND press enter to continue");
Terminal.ReadString (InputStr);
Terminal.WriteLn;
ContinueOn := TRUE;
END DiskRequestProc;
PROCEDURE FileRestoreProc
(FileName : IN FullType;
ContinueOn : IN out BOOLEAN);
BEGIN
Terminal.WriteString ("REStoRING UP " & FileName);
Terminal.WriteLn;
ContinueOn := TRUE;
END FileRestoreProc;
BEGIN
MyRestore ("B:","C:\*.*");
END TestRES;
*)
PROCEDURE GetFileInformation
(CONST File : ARRAY OF CHAR;
VAR FileSize : ModSys.INT32;
VAR FileAttribute : CARDINAL;
VAR FileTime : ModSys.INT32;
VAR FileDate : ModSys.INT32;
VAR Success : BOOLEAN);
(**
GetFileInformation - : information about a file.
This procedure will return internal DOS file information
CALLING SEQUENCE -
GetFileInformation (FileName, FileSize, FileAttr,
FileTime, FileDate, Success);
ENTRY -
FileName : ARRAY OF CHAR
The name of the file
EXIT -
FileSize : ModSys.INT32
The size OF file IN bytes
FileAttr : ModSys.SNatural
The attribute OF the file
FileTime : ModSys.SInteger
The DOS packed file time
FileDate : ModSys.SInteger
The DOS packed file date
Success : BOOLEAN
TRUE - Operation worked.
FALSE - Operation failed.
*)
PROCEDURE PackedDateToDate
(CONST PackedDate : ModSys.INT32;
VAR Year : CARDINAL;
VAR Month : CARDINAL;
VAR Day : CARDINAL);
(**
PackedDateToDate - Return a date IN YY,MM,DD from a DOS packed date.
This procedure converts a packed date to years, months AND days
CALLING SEQUENCE -
PackedDateToDate (PackedDate, Year, Month, Day);
ENTRY -
PackedDate : ModSys.INT32
The packed date value
EXIT -
Year : ModSys.SNatural
The Year (0-9999)
Month : ModSys.SNatural
The Month [0-12)
Day : ModSys.SNatural
The day [0-31)
*)
PROCEDURE PackedTimeToTime
(CONST PackedTime : ModSys.INT32;
VAR Hour : CARDINAL;
VAR Minute : CARDINAL;
VAR Second : CARDINAL);
(**
PackedTimeToTime - Return a time IN HH:MM:SS from a DOS packed time.
This procedure converts a packed time to hours, minutes, AND seconds.
CALLING SEQUENCE -
PackedTimeToTime (PackedTime, Hour, Min, Sec);
ENTRY -
PackedTime : ModSys.ModSys.INT32
The packed time value
EXIT -
Hour : ModSys.SNatural
The hour (0-23)
Minute : ModSys.SNatural
The hour (0-59)
Second : ModSys.SNatural
The second (0-59)
*)
PROCEDURE DirectoryQuery
(VAR StartPath : ARRAY OF CHAR;
CONST DirectoryProc : DirectoryProcType);
(**
DirectoryQuery - This routine will perform a directory traversal.
This procedure will traverse the directory structure starting IMPORT the
starting path. Each time a new directory is located the routine will
call the USER supplied DirectoryProc. The DirectoryProc may stop the
the traversal BY returning continue=FALSE. Each time the USER supplied
PROCEDURE is called the current directory name is passed to the
DirectoryProc. The starting path must be a valid path IMPORT optional drive
examples are : c:\test\, c:\, \ etc... IF no drive is specified in
the starting path the drive will NOT be returned as part OF the directory
name to the USER supplied routine.
CALLING SEQUENCE -
MyDirectoryQuery (DirectoryName);
ENTRY -
DirectoryName : ARRAY OF CHAR
A valid MS-DOS path IMPORT an optional drive
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestDirectoryQuery;
DirectoryName : string[0..76)[0] := ASCIIX.nul;
PROCEDURE Dirq
(DirName : IN ARRAY OF CHAR;
ContinueOn : IN out BOOLEAN);
PROCEDURE MyDirectoryQuery is new DiskLib.DirectoryQuery
(DirQ);
PROCEDURE Dirq
(DirName : IN ARRAY OF CHAR;
ContinueOn : IN out BOOLEAN);
BEGIN
Terminal.WriteString (DirName);
Terminal.WriteLn;
END Dirq;
BEGIN
Terminal.WriteLn;
Terminal.WriteLn;
Terminal.WriteString ("Enter Directory to start traversal :");
Terminal.ReadString (DirectoryName);
Terminal.WriteLn;
Terminal.WriteLn;
MyDirectoryQuery (DirectoryName);
END TestDirectoryQuery;
*)
PROCEDURE SetVolumeLabel
(CONST Volume : ARRAY OF CHAR;
CONST TheLabel : ARRAY OF CHAR) : BOOLEAN;
(**
SetVolumeLabel - Set the volume label of the specified drive.
This procedure sets the volume LABEL OF the specified drive.
This call is equivalent to the MS-DOS LABEL command.
CALLING SEQUENCE -
SetVolumeLabel (drive, TheLabel);
ENTRY -
drive : DriveType
The drive to return the volume of
TheLabel : ARRAY OF CHAR
The MS-DOS volume label
EXAMPLE -
IMPORT DiskLib;
PROCEDURE TestSL;
BEGIN
DiskLib.SetVolumeLabel ("C:","DOS50120");
END TestSL;
*)
PROCEDURE GetVolumeLabel
(CONST Volume : ARRAY OF CHAR;
VAR TheLabel : ARRAY OF CHAR);
(**
GetVolumeLabel - Get the volume label of the specified drive.
This procedure returns the volume label of the specified drive.
This call is equivalent to the MS-DOS VOL command.
CALLING SEQUENCE -
GetVolumeLabel (drive, TheLabel);
ENTRY -
drive : DriveType
The drive to return the volume of
EXIT -
TheLabel : ARRAY OF CHAR
The MS-DOS volume label
EXAMPLE -
IMPORT DiskLib;
IMPORT Terminal;
PROCEDURE TestGL;
VAR
TheLabel : ARRAY [0..10] OF CHAR = ASCIIX.nul;
BEGIN
DiskLib.GetVolumeLabel ("C:", TheLabel);
Terminal.WriteString ("VOLUME LABEL IS " & TheLabel);
Terminal.WriteLn;
END TestGL;
*)
PROCEDURE FormatFloppyDrive
(CONST Hwnd : WIN32.HWND;
CONST Drive : ARRAY OF CHAR;
CONST DefaultQuick : BOOLEAN;
VAR Success : BOOLEAN);
(**
FormatFloppyDrive - Format a floppy drive diskette.
This procedure will format a floppy drive diskette. It will not
format any fixed drive media.
NOTE - This routine is available only for Windows 2000 and up.
CALLING SEQUENCE -
FormatFloppyDrive (Hwnd, Drive, DefaultQuick, Success);
ENTRY -
Hwnd : WIN32.HWND
The Hwnd of the current window. When the format dialog is displayed
it MUST have a parent window. This will be the Hwnd of either the
current SageTerm of Dialog that is displayed when this routine is
called.
To get the Hwnd of a SageTerm use -
Hwnd := SageTerm.GetWindowHandle ();
To get the Hwnd of a dialog use -
Hwnd := DWLib.LookUpHwnd (Dialog.CurrentDialogID (MessageData),
0);
Drive : ARRAY OF CHAR
The drive containing the volume to be formatted. The only
acceptable values are "A", "A:", "a", "a:", "B", "B:", "b" or
"b:". Any other values passed to the routine will cause it to
fail.
DefaultQuick : BOOLEAN
TRUE - Start the dialog with the Quick Format checked.
FALSE - Start the dialog with the Quick Format unchecked.
EXIT -
Success : BOOLEAN
TRUE - The last attempted format was successful.
FALSE - The last attempted format was not successful. This could be
either the user cancelled out or there was an error during
the formatting.
EXAMPLE -
IMPORT DiskLib;
PROCEDURE TestFormat;
VAR
Success : BOOLEAN = FALSE;
BEGIN
DiskLib.FormatFloppyDrive (Hwnd, "A", FALSE, FALSE, Success);
END TestFormat;
*)
Send mail to
warren.merrill@inl.gov
with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance