![]() |
|
![]() |
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 = packed record
Full : FullType;
Drive : DriveType;
Directory : DirectoryType;
FileName : NameType;
Extension : ExtensionType;
end;
// record
QueryType = (AndQuery,
OrQuery);
PreDeleteProcType = procedure
(const FileName : array of char;
var DeleteOk : boolean); stdcall;
PostDeleteProcType = procedure
(const FileName : array of char;
var DeleteState : Files.FileState); stdcall;
PostLocateProcType = procedure
(const DiskRecord : DiskRecordType;
var ContinueOn : boolean); stdcall;
DiskRequestProcType = procedure
(const DiskNumber : cardinal;
var ContinueOn : boolean); stdcall;
FileBackupProcType = procedure
(const FileName : array of char;
var ContinueOn : boolean); stdcall;
FileRestoreProcType = procedure
(const FileName : array of char;
var ContinueOn : boolean); stdcall;
DirectoryProcType = procedure
(const DirName : array of char;
var ContinueOn : boolean); stdcall;
function DriveValid
(const Drive : array of char) : boolean; overload; stdcall;
exports DriveValid (const Drive : array of char) name 'DiskLib_DriveValid';
//*
// 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 begin
// Terminal.WriteString ('DRIVE T IS ACCESSABLE');
// Terminal.WriteLn;
// end else begin
// Terminal.WriteString ('DRIVE T IS NOT ACCESSIBLE');
// Terminal.WriteLn;
// end;
// end; // TestDV
//
function DriveValid
(const Drive : string) : boolean; overload; stdcall;
exports DriveValid (const Drive : string) name 'DiskLib_STRDriveValid';
//*
// STRDriveValid - See documentation of DriveValid.
//
function DriveReady
(const Drive : array of char) : boolean; overload; stdcall;
exports DriveReady (const Drive : array of char) name 'DiskLib_DriveReady';
//*
// 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 begin
// Terminal.WriteString ('DRIVE A IS READY');
// Terminal.WriteLn;
// end else begin
// Terminal.WriteString ('DRIVE A IS NOT READY');
// Terminal.WriteLn;
// end;
// end; // TestDR
//
function DriveReady
(const Drive : string) : boolean; overload; stdcall;
exports DriveReady (const Drive : string) name 'DiskLib_STRDriveReady';
//*
// STRDriveReady - See documentation of DriveReady.
//
function DriveIsWritable
(const Drive : array of char) : boolean; overload; stdcall;
exports DriveIsWritable (const Drive : array of char) name 'DiskLib_DriveIsWritable';
//*
// 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 begin
// Terminal.WriteString ('DRIVE A IS READY');
// Terminal.WriteLn;
// end else begin
// Terminal.WriteString ('DRIVE A IS NOT READY');
// Terminal.WriteLn;
// end;
// end; // TestDR
//
function DriveIsWritable
(const Drive : string) : boolean; overload; stdcall;
exports DriveIsWritable (const Drive : string) name 'DiskLib_STRDriveIsWritable';
//*
// STRDriveIsWritable - See documentation of DriveIsWritable.
//
procedure SetAttribute
(const FileName : array of char;
const Normal : boolean;
const ReadOnly : boolean;
const Archive : boolean;
const SystemAttrib : boolean;
const Hidden : boolean); overload; stdcall;
exports SetAttribute (const FileName : array of char;
const Normal : boolean;
const ReadOnly : boolean;
const Archive : boolean;
const SystemAttrib : boolean;
const Hidden : boolean) name 'DiskLib_SetAttribute';
//*
// 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.
//
// EXAMPLE -
//
// IMPORT DiskLib;
// IMPORT Terminal;
//
// procedure TestSA;
// begin
// SetAttribute ('*.DAT', False,False, False,True);
// end; // TestSA
//
procedure SetAttribute
(const FileName : string;
const Normal : boolean;
const ReadOnly : boolean;
const Archive : boolean;
const SystemAttrib : boolean;
const Hidden : boolean); overload; stdcall;
exports SetAttribute (const FileName : string;
const Normal : boolean;
const ReadOnly : boolean;
const Archive : boolean;
const SystemAttrib : boolean;
const Hidden : boolean) name 'DiskLib_STRSetAttribute';
//*
// STRSetAttribute - See documentation of SetAttribute.
//
procedure DeleteFiles
(const FileName : array of char;
const PreDeleteProc : PreDeleteProcType;
const PostDeleteProc : PostDeleteProcType); overload; stdcall;
exports DeleteFiles (const FileName : array of char;
const PreDeleteProc : PreDeleteProcType;
const PostDeleteProc : PostDeleteProcType) name 'Disklib_DeleteFiles';
//*
// 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
//
// 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 end else begin ch = 'y' then begin
// deleteOK := True;
// end else begin
// deleteOK := False;
// end;
// end; // MyPreDelete
//
//
// procedure MyPostDelete
// (fileName : IN array of char;
// deleteState : IN out Files.FileState);
// begin
// if deleteState = Files.ok then begin
// Terminal.WriteString ('File deleted : File = ' & FileName);
// Terminal.WriteLn;
// end else begin
// 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 DeleteFiles
(const FileName : string;
const PreDeleteProc : PreDeleteProcType;
const PostDeleteProc : PostDeleteProcType); overload; stdcall;
exports DeleteFiles (const FileName : string;
const PreDeleteProc : PreDeleteProcType;
const PostDeleteProc : PostDeleteProcType) name 'Disklib_STRDeleteFiles';
//*
// STRDeleteFiles - See documentation of DeleteFiles.
//
function AvailableDiskSpace
(const Drive : array of char) : ModSys.FLOAT32; overload; stdcall;
exports AvailableDiskSpace (const Drive : array of char) name 'DiskLib_AvailableDiskSpace';
//*
// 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) := ASCIIX.nul;
// success : boolean = False;
// begin
// Terminal.WriteLn;
// space := DiskLib.AvailableDiskSpace ('C:');
// if Space < 0.0 then begin
// Terminal.WriteString ('INVALID DRIVE OR NOT READY OR OTHER ERROR');
// Terminal.WriteLn;
// end else begin
// ConvertReal.LongFloatToStr (space,str,18,0,success);
// Terminal.WriteString ('Available disk space on drive C: IS : ' & str);
// Terminal.WriteLn;
// end;
// end; // TestAvailableDiskSpace
//
function AvailableDiskSpace
(const Drive : string) : ModSys.FLOAT32; overload; stdcall;
exports AvailableDiskSpace (const Drive : string) name 'DiskLib_STRAvailableDiskSpace';
//*
// STRAvailableDiskSpace - See documentation of AvailableDiskSpace.
//
function TotalDiskCapacity
(const Drive : array of char) : ModSys.FLOAT32; overload; stdcall;
exports TotalDiskCapacity (const Drive : array of char) name 'DiskLib_TotalDiskCapacity';
//*
// 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) := ASCIIX.nul;
// success : boolean = False;
// begin
// Terminal.WriteLn;
// space := DiskLib.TotalDiskCapacity ('C:');
// if Space < 0.0 then begin
// Terminal.WriteString ('INVALID DRIVE OR NOT READY OR OTHER ERROR');
// Terminal.WriteLn;
// end else begin
// ConvertReal.LongFloatToStr (space,str,18,0,success);
// Terminal.WriteString ('Total disk capacity on drive C: IS : ' & str);
// Terminal.WriteLn;
// end;
// end; // TestTotalDiskCapacity
//
function TotalDiskCapacity
(const Drive : string) : ModSys.FLOAT32; overload; stdcall;
exports TotalDiskCapacity (const Drive : string) name 'DiskLib_STRTotalDiskCapacity';
//*
// STRTotalDiskCapacity - See documentation of TotalDiskCapacity.
//
procedure MakeDirectory
(const Path : array of char;
var Success : boolean); overload; stdcall;
exports MakeDirectory (const Path : array of char;
var Success : boolean) name 'Disklib_MakeDirectory';
//*
// 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 MakeDirectory
(const Path : string;
var Success : boolean); overload; stdcall;
exports MakeDirectory (const Path : string;
var Success : boolean) name 'Disklib_STRMakeDirectory';
//*
// STRMakeDirectory - See documentation of MakeDirectory.
//
procedure RemoveDirectory
(const Path : array of char;
var Success : boolean); overload; stdcall;
exports RemoveDirectory (const Path : array of char;
var Success : boolean) name 'DiskLib_RemoveDirectory';
//*
// 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 RemoveDirectory
(const Path : string;
var Success : boolean); overload; stdcall;
exports RemoveDirectory (const Path : string;
var Success : boolean) name 'DiskLib_STRRemoveDirectory';
//*
// STRRemoveDirectory - See documentation of RemoveDirectory.
//
procedure ChangeDirectory
(const Path : array of char;
var Success : boolean); overload; stdcall;
exports ChangeDirectory (const Path : array of char;
var Success : boolean) name 'DiskLib_ChangeDirectory';
//*
// 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 ChangeDirectory
(const Path : string;
var Success : boolean); overload; stdcall;
exports ChangeDirectory (const Path : string;
var Success : boolean) name 'DiskLib_STRChangeDirectory';
//*
// STRChangeDirectory - See documentation of ChangeDirectory.
//
procedure GetCurrentDirectory
(var Directory : array of char); overload; stdcall;
exports GetCurrentDirectory (var Directory : array of char) name 'DiskLib_GetCurrentDirectory';
//*
// GetCurrentDirectory - Get the current logged directory.
//
//
// This procedure will : 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 GetCurrentDirectory
(var Directory : string); overload; stdcall;
exports GetCurrentDirectory (var Directory : string) name 'DiskLib_STRGetCurrentDirectory';
//*
// STRGetCurrentDirectory - See documentation of GetCurrentDirectory.
//
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); overload; stdcall;
exports 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) name 'DiskLib_FindFirstMatch';
//*
// 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 begin
// Terminal.WriteString ('Matching file: ' &
// DiskRecord.Full);
// Terminal.WriteLn;
// end;
//
// end; // TestFF
//
procedure FindFirstMatch
(const Search : string;
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); overload; stdcall;
exports FindFirstMatch (const Search : string;
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) name 'DiskLib_STRFindFirstMatch';
//*
// STRFindFirstMatch - See documentation of FindFirstMatch.
//
procedure FindNextMatch
(var DiskRec : DiskRecordType;
var Success : boolean); stdcall;
exports FindNextMatch name 'DiskLib_FindNextMatch';
//*
// 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 begin
// 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); overload; stdcall;
exports 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) name 'DiskLib_DiskQuery';
//*
// 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 DiskQuery
(const Search : string;
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); overload; stdcall;
exports DiskQuery (const Search : string;
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) name 'DiskLib_STRDiskQuery';
//*
// STRDiskQuery - See documentation of DiskQuery.
//
procedure Backup
(const Source : array of char;
const DestDrive : array of char;
const DiskRequestProc : DiskRequestProcType;
const FileBackupProc : FileBackupProcType); overload; stdcall;
exports Backup (const Source : array of char;
const DestDrive : array of char;
const DiskRequestProc : DiskRequestProcType;
const FileBackupProc : FileBackupProcType) name 'DiskLib_Backup';
//*
// 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 cardinal;
// ContinueOn : IN out boolean);
//
// procedure FileBackupProc
// (FileName : IN FullType;
// ContinueOn : IN out boolean);
//
// MyBackup is new DiskLib.Backup (DiskRequestProc,FileBackupProc);
//
//
// procedure DiskRequestProc
// (DiskNumber : IN cardinal;
// ContinueOn : IN out boolean);
// begin
// Terminal.WriteString ('Enter diskette # ' &
// cardinal'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 Backup
(const Source : string;
const DestDrive : string;
const DiskRequestProc : DiskRequestProcType;
const FileBackupProc : FileBackupProcType); overload; stdcall;
exports Backup (const Source : string;
const DestDrive : string;
const DiskRequestProc : DiskRequestProcType;
const FileBackupProc : FileBackupProcType) name 'DiskLib_STRBackup';
//*
// STRBackup - See documentation of Backup.
//
procedure Restore
(const SourceDrive : array of char;
const Dest : array of char;
const DiskRequestProc : DiskRequestProcType;
const FileRestoreProc : FileRestoreProcType); overload; stdcall;
exports Restore (const SourceDrive : array of char;
const Dest : array of char;
const DiskRequestProc : DiskRequestProcType;
const FileRestoreProc : FileRestoreProcType) name 'DiskLib_Restore';
//*
// 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 cardinal;
// ContinueOn : IN out boolean);
//
// procedure FileRestoreProc
// (FileName : IN FullType;
// ContinueOn : IN out boolean);
//
// MyBackup is new DiskLib.Restore (DiskRequestProc,FileBackupProc);
//
//
// procedure DiskRequestProc
// (DiskNumber : IN cardinal;
// ContinueOn : IN out boolean);
// begin
// Terminal.WriteString ('Enter diskette # ' &
// cardinal'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 Restore
(const SourceDrive : string;
const Dest : string;
const DiskRequestProc : DiskRequestProcType;
const FileRestoreProc : FileRestoreProcType); overload; stdcall;
exports Restore (const SourceDrive : string;
const Dest : string;
const DiskRequestProc : DiskRequestProcType;
const FileRestoreProc : FileRestoreProcType) name 'DiskLib_STRRestore';
//*
// STRRestore - See documentation of Restore.
//
procedure GetFileInformation
(const FileName : array of char;
var FileSize : ModSys.INT32;
var FileAttribute : cardinal;
var FileTime : ModSys.INT32;
var FileDate : ModSys.INT32;
var Success : boolean); overload; stdcall;
exports GetFileInformation (const FileName : array of char;
var FileSize : ModSys.INT32;
var FileAttribute : cardinal;
var FileTime : ModSys.INT32;
var FileDate : ModSys.INT32;
var Success : boolean) name 'DiskLib_GetFileInformation';
//*
// GetFileInformation - return information about a file.
//
//
// This procedure will return internal 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 : cardinal
// 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 GetFileInformation
(const FileName : string;
var FileSize : ModSys.INT32;
var FileAttribute : cardinal;
var FileTime : ModSys.INT32;
var FileDate : ModSys.INT32;
var Success : boolean); overload; stdcall;
exports GetFileInformation (const FileName : string;
var FileSize : ModSys.INT32;
var FileAttribute : cardinal;
var FileTime : ModSys.INT32;
var FileDate : ModSys.INT32;
var Success : boolean) name 'DiskLib_STRGetFileInformation';
//*
// STRGetFileInformation - See documentation of GetFileInformation.
//
procedure PackedDateToDate
(const PackedDate : ModSys.INT32;
var Year : cardinal;
var Month : cardinal;
var Day : cardinal); stdcall;
exports PackedDateToDate name 'DiskLib_PackedDateToDate';
//*
// PackedDateToDate - : 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 : cardinal
// The Year (0-9999)
//
// Month : cardinal
// The Month [0-12)
//
// Day : cardinal
// The day [0-31)
//
procedure PackedTimeToTime
(const PackedTime : ModSys.INT32;
var Hour : cardinal;
var Minute : cardinal;
var Second : cardinal); stdcall;
exports PackedTimeToTime name 'DiskLib_PackedTimeToTime';
//*
// PackedTimeToTime - : 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 : cardinal
// The hour (0-23)
//
// Minute : cardinal
// The hour (0-59)
//
// Second : cardinal
// The second (0-59)
//
procedure DirectoryQuery
(var StartPath : array of char;
const DirectoryProc : DirectoryProcType); overload; stdcall;
exports DirectoryQuery (var StartPath : array of char;
const DirectoryProc : DirectoryProcType) name 'DiskLib_DirectoryQuery';
//*
// 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 path with an optional drive
//
// EXAMPLE -
//
// IMPORT DiskLib;
// IMPORT Terminal;
//
// procedure TestDirectoryQuery;
//
// DirectoryName : string[0..76) := 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 DirectoryQuery
(var StartPath : string;
const DirectoryProc : DirectoryProcType); overload; stdcall;
exports DirectoryQuery (var StartPath : string;
const DirectoryProc : DirectoryProcType) name 'DiskLib_STRDirectoryQuery';
//*
// STRDirectoryQuery - See documentation of DirectoryQuery.
//
function SetVolumeLabel
(const Volume : array of char;
const VolLabel : array of char) : boolean; overload; stdcall;
exports SetVolumeLabel (const Volume : array of char;
const VolLabel : array of char) name 'DiskLib_SetVolumeLabel';
//*
// 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 (Volume, VolLabel);
//
// ENTRY -
//
// drive : DriveType
// The drive to return the volume of
//
// VolLabel : array of char
// The volume label
//
// EXAMPLE -
//
// IMPORT DiskLib;
//
// procedure TestSL;
// begin
// DiskLib.SetVolumeLabel ('C:','DOS50120');
// end; // TestSL
//
function SetVolumeLabel
(const Volume : string;
const VolLabel : string) : boolean; overload; stdcall;
exports SetVolumeLabel (const Volume : string;
const VolLabel : string) name 'DiskLib_STRSetVolumeLabel';
//*
// STRSetVolumeLabel - See documentation of SetVolumeLabel.
//
procedure GetVolumeLabel
(const Volume : array of char;
var VolLabel : array of char); overload; stdcall;
exports GetVolumeLabel (const Volume : array of char;
var VolLabel : array of char) name 'DiskLib_GetVolumeLabel';
//*
// 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 (Volume, VolLabel);
//
// ENTRY -
//
// Volume : DriveType
// The drive to return the volume of
//
// EXIT -
//
// VolLabel : array of char
// The volume label
//
// EXAMPLE -
//
// IMPORT DiskLib;
// IMPORT Terminal;
//
// procedure TestGL;
// ar
// Label : array [0..10] of char = ASCIIX.nul;
// begin
// DiskLib.GetVolumeLabel ('C:', Label);
// Terminal.WriteString ('VOLUME LABEL IS ' & Label);
// Terminal.WriteLn;
// end; // TestGL
//
procedure GetVolumeLabel
(const Volume : string;
var VolLabel : array of char); overload; stdcall;
exports GetVolumeLabel (const Volume : string;
var VolLabel : array of char) name 'DiskLib_STRGetVolumeLabel';
//*
// STRGetVolumeLabel - See documentation of GetVolumeLabel.
//
procedure GetVolumeLabel
(const Volume : string;
var VolLabel : string); overload; stdcall;
exports GetVolumeLabel (const Volume : string;
var VolLabel : string) name 'DiskLib_STRSTRGetVolumeLabel';
//*
// STRSTRGetVolumeLabel - See documentation of GetVolumeLabel.
//
procedure FormatFloppyDrive
(const Hwnd : Windows.Hwnd;
const Drive : array of char;
const DefaultQuick : boolean;
var Success : boolean); overload; stdcall;
exports FormatFloppyDrive (const Hwnd : Windows.Hwnd;
const Drive : array of char;
const DefaultQuick : boolean;
var Success : boolean) name 'DiskLib_FormatFloppyDrive';
//*
// 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 : Windows.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
//
procedure FormatFloppyDrive
(const Hwnd : Windows.Hwnd;
const Drive : string;
const DefaultQuick : boolean;
var Success : boolean); overload; stdcall;
exports FormatFloppyDrive (const Hwnd : Windows.Hwnd;
const Drive : string;
const DefaultQuick : boolean;
var Success : boolean) name 'DiskLib_STRFormatFloppyDrive';
//*
// STRFormatFloppyDrive - See documentation of FormatFloppyDrive.
//
Send mail to
warren.merrill@inl.gov
with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance