Sage-ST ä

Disklib

Documentation

Global Declarations (Constants, Types, Variables)
AvailableDiskSpace Backup ChangeDirectory
DeleteFiles DirectoryQuery DiskQuery DriveIsWritable
DriveReady DriveValid FindFirstMatch FindNextMatch
FormatFloppyDrive GetCurrentDirectory GetFileInformation GetVolumeLabel
MakeDirectory PackedDateToDate PackedTimeToTime RemoveDirectory
Restore SetAttribute SetVolumeLabel TotalDiskCapacity




  Delimiter         : constant character := ASCIIX.BackSlash;
  DriveLength       : constant := 4;
  DirectoryLength   : constant := 151;
  NameLength        : constant := 76;
  ExtensionLength   : constant := 16;
  VolumeLabelLength : constant := 13;
  FullLength        : constant := DriveLength + DirectoryLength + NameLength + ExtensionLength;

  subtype DriveType is string (1 .. DriveLength);

  subtype DirectoryType is string (1 .. DirectoryLength);

  subtype NameType is string (1 .. NameLength);

  subtype ExtensionType is string (1 .. ExtensionLength);

  subtype FullType is string (1 .. FullLength);

  subtype VolumeLabelType is string (1 .. VolumeLabelLength);

  type DiskRecordType is record
    Full      : FullType := (others => ASCIIX.nul);
    Drive     : DriveType := (others => ASCIIX.nul);
    Directory : DirectoryType := (others => ASCIIX.nul);
    FileName  : NameType := (others => ASCIIX.nul);
    Extension : ExtensionType := (others => ASCIIX.nul);
  end record;

  for DiskRecordType use record
    Full at 0 range 0 .. FullLength * 8 - 1;
    Drive at 247 range 0 .. DriveLength * 8 - 1;
    Directory at 251 range 0 .. DirectoryLength * 8 - 1;
    FileName at 402 range 0 .. NameLength * 8 - 1;
    Extension at 478 range 0 .. ExtensionLength * 8 - 1;
  end record;

  type QueryType is (AndQuery,
                     OrQuery);

  type PreDeleteProcType is access
  procedure (FileName      : in     System.Address;
             FileName_High : in     ModSys.S_Natural;
             DeleteOk      : in out boolean);

  pragma Convention
          (WIN32,
           PreDeleteProcType);

  type PostDeleteProcType is access
  procedure (FileName      : in     System.Address;
             FileName_High : in     ModSys.S_Natural;
             DeleteState   : in out Files.FileState);

  pragma Convention
          (WIN32,
           PostDeleteProcType);

  type PostLocateProcType is access
  procedure (DiskRecord : in     DiskRecordType;
             ContinueOn : in out boolean);

  pragma Convention
          (WIN32,
           PostLocateProcType);

  type DiskRequestProcType is access
  procedure (DiskNumber : in     ModSys.S_Natural;
             ContinueOn : in out boolean);

  pragma Convention
          (WIN32,
           DiskRequestProcType);

  type FileBackupProcType is access
  procedure (FileName      : in     System.Address;
             FileName_High : in     ModSys.S_Natural;
             ContinueOn    : in out boolean);

  pragma Convention
          (WIN32,
           FileBackupProcType);

  type FileRestoreProcType is access
  procedure (FileName      : in     System.Address;
             FileName_High : in     ModSys.S_Natural;
             ContinueOn    : in out boolean);

  pragma Convention
          (WIN32,
           FileRestoreProcType);

  type DirectoryProcType is access
  procedure (DirName      : in     System.Address;
             DirName_High : in     ModSys.S_Natural;
             ContinueOn   : in out boolean);

  pragma Convention
          (WIN32,
           DirectoryProcType);




  function DriveValid
            (Drive : in     string) return 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 -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestDV is
  --    Begin
  --      if DriveValid("T:") then
  --        TermX.WriteString("DRIVE T IS ACCESSABLE");
  --        TermX.WriteLn;
  --      else
  --        TermX.WriteString("DRIVE T IS NOT ACCESSIBLE");
  --        TermX.WriteLn;
  --      end if;
  --    end TestDV;
  --




  function DriveReady
            (Drive : in     string) return 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 -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestDR is
  --    Begin
  --      if DriveReady("A:") then
  --        TermX.WriteString("DRIVE A IS READY");
  --        TermX.WriteLn;
  --      else
  --        TermX.WriteString("DRIVE A IS NOT READY");
  --        TermX.WriteLn;
  --      end if;
  --    end TestDR;
  --




  function DriveIsWritable
            (Drive : in     string) return 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 -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestDR is
  --    Begin
  --      if DiskLib.DriveIsWritable("A:") then
  --        TermX.WriteString("DRIVE A IS READY");
  --        TermX.WriteLn;
  --      else
  --        TermX.WriteString("DRIVE A IS NOT READY");
  --        TermX.WriteLn;
  --      end if;
  --    end TestDR;
  --




  procedure SetAttribute
             (FileName  : in     string;
              Normal    : in     boolean;
              ReadOnly  : in     boolean;
              Archive   : in     boolean;
              SystemAtt : in     boolean;
              Hidden    : in     boolean);

  --*
  --  SetAttribute - Set attribute on file(s).
  --
  --
  --  This procedure sets the attribute of a file or files.  The attributes are
  --  Read-only, Archive, System and Hidden.  Wild cards may be used.
  --
  --  CALLING SEQUENCE -
  --
  --    SetAttribute (FileName);
  --
  --  ENTRY -
  --
  --    FileName : string
  --      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.
  --
  --    System : 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 -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestSA is
  --    Begin
  --      SetAttribute("*.DAT",False,False,False,True);
  --    end TestSA;
  --




  procedure DeleteFiles
             (FileName       : in     string;
              PreDeleteProc  : in     PreDeleteProcType;
              PostDeleteProc : in     PostDeleteProcType);

  --*
  --  DeleteFiles - Delete files.
  --
  --
  --  This procedure deletes the specified files.  Wild cards and paths are
  --  allowed.  The DeleteFiles procedure is instantiated with 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     string;
  --                  deleteOK : in out boolean);
  --
  --      procedure PostDelete
  --                 (filename    : in     string;
  --                  deleteState : in out Files.FileState);
  --
  --  This procedure will only delete 'ordinary' files.  System, hidden, volume,
  --  and directory files will not be deleted.
  --
  --  CALLING SEQUENCE -
  --
  --    DeleteFiles (FileName, PreDelete, PostDelete);
  --
  --  ENTRY -
  --
  --    FileName : string
  --      The filename(s) to delete - may use DOS wild cards and valid path
  --
  --  EXIT -
  --
  --    None
  --      N/A
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --    with TermX;
  --    with Files;
  --
  --    procedure TestDeleteFiles is
  --
  --      FileName : SageSpec.LongPathType := (others => ' ');
  --      ch       : character := ' ';
  --
  --      procedure MyPreDelete
  --                 (fileName : in     string;
  --                  deleteOK : in out boolean) is
  --
  --      begin
  --        TermX.WriteString("ok to delete ? (Y/N) File =  " & FileName);
  --        TermX.ReadChar(ch);
  --        TermX.WriteLn;
  --        if ch = 'Y' or else ch = 'y' then
  --          deleteOK := true;
  --        else
  --          deleteOK := false;
  --        end if;
  --      end MyPreDelete;
  --
  --
  --      procedure MyPostDelete
  --                 (fileName    : in     string;
  --                  deleteState : in out Files.FileState) is
  --      begin
  --        if deleteState = Files.ok then
  --          TermX.WriteString("File deleted : File = " & FileName);
  --          TermX.WriteLn;
  --        else
  --          TermX.WriteString("File not deleted, error = " & Files.FileState'image(deletestate) & " File = " & FileName);
  --          TermX.WriteLn;
  --        end if;
  --      end MyPostDelete;
  --
  --
  --      procedure MyDelete is new DiskLib.DeleteFiles
  --                 (MyPreDelete,MyPostDelete);
  --
  --    begin
  --      TermX.WriteLn;
  --      TermX.WriteLn;
  --      TermX.WriteString("Enter FileName to delete :");
  --      TermX.ReadString(FileName);
  --      TermX.WriteLn;
  --      MyDelete(FileName);
  --
  --    end TestDeleteFiles;
  --




  function AvailableDiskSpace
            (Drive : in     string) return ModSys.S_Float;

  --*
  --  AvailableDiskSpace - Check the amount of available disk space.
  --
  --
  --  This function 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.S_Float
  --      the amount of disk space in bytes (note 123 bytes = 123.0 bytes)
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --    with TermX;
  --    with ConvertReal;
  --
  --    procedure TestAvailableDiskSpace is
  --      space    : long_float := 0.0;
  --      Str      : string(1..20) := (others => ASCIIX.nul);
  --      success  : boolean := false;
  --    begin
  --      TermX.WriteLn;
  --      space := DiskLib.AvailableDiskSpace("C:");
  --      if Space < 0.0 then
  --        TermX.WriteString("INVALID DRIVE OR NOT READY OR OTHER ERROR");
  --        TermX.WriteLn;
  --      else
  --        ConvertReal.FloatToStr(space,str,18,0,success);
  --        TermX.WriteString("Available disk space on drive C: IS  : " & str);
  --        TermX.WriteLn;
  --      end if;
  --    end TestAvailableDiskSpace;
  --




  function TotalDiskCapacity
            (Drive : in     string) return ModSys.S_Float;

  --*
  --  TotalDiskCapacity - Check the amount of total disk space.
  --
  --
  --  This function 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.S_Float
  --      the amount of disk capacity in bytes (note 123 bytes = 123.0 bytes)
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --    with TermX;
  --    with ConvertReal;
  --
  --    procedure TestTotalDiskCapacity is
  --      space    : long_float := 0.0;
  --      Str      : string(1..20) := (others => ASCIIX.nul);
  --      success  : boolean := false;
  --    begin
  --      TermX.WriteLn;
  --      space := DiskLib.TotalDiskCapacity("C:");
  --      if Space < 0.0 then
  --        TermX.WriteString("INVALID DRIVE OR NOT READY OR OTHER ERROR");
  --        TermX.WriteLn;
  --      else
  --        ConvertReal.FloatToStr(space,str,18,0,success);
  --        TermX.WriteString("Total disk capacity on drive C: IS  : " & str);
  --        TermX.WriteLn;
  --      end if;
  --    end TestTotalDiskCapacity;
  --




  procedure MakeDirectory
             (Path    : in     string;
              Success :    out boolean);

  --*
  --  MakeDirectory - Create a DOS directory.
  --
  --
  --  This procedure will perform the same function as the MS-DOS MD command.
  --  Refer to the MS-DOS documentation for further information.
  --
  --  CALLING SEQUENCE -
  --
  --    MakeDirectory ("\TEST\TEMP", Success);
  --
  --  ENTRY -
  --
  --    Path : string
  --      The name of the directory to create.  Do not include a trailing delimiter.
  --
  --  EXIT -
  --
  --    Success : Boolean
  --      True - Operation worked.
  --      False - Operation failed.
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --
  --    procedure TestMD is
  --    begin
  --      DiskLib.MakeDirectory ("\TEST\TEMP", Success);
  --    end TestMD;
  --




  procedure RemoveDirectory
             (Path    : in     string;
              Success :    out boolean);

  --*
  --  RemoveDirectory - Remove a DOS directory.
  --
  --
  --  This procedure will perform the same function 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");
  --
  --  ENTRY -
  --
  --    Path : string
  --      The name of the directory to remove.  Do not include a trailing delimiter.
  --
  --  EXIT -
  --
  --    Success : boolean
  --      True - Operation worked.
  --      False - Operation failed.
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --
  --    procedure TestRD is
  --    begin
  --      DiskLib.RemoveDirectory ("\TEST\TEMP", Success);
  --    end TestRD;
  --




  procedure ChangeDirectory
             (Path    : in     string;
              Success :    out boolean);

  --*
  --  ChangeDirectory - Change to a directory.
  --
  --
  --  This procedure will perform the same function as the MS-DOS CD command.
  --  Refer to the MS-DOS documentation for further information.
  --
  --  CALLING SEQUENCE -
  --
  --    ChangeDirectory ("\TEST\TEMP", Success);
  --
  --  ENTRY -
  --
  --    Path : string
  --      The name of the directory to move to.  Do not include the trailing delimiter.
  --
  --  EXIT -
  --
  --    Success : boolean
  --      True - Operation worked.
  --      False - Operation failed.
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --
  --    procedure TestCD is
  --    begin
  --      DiskLib.ChangeDirectory ("\TEST\TEMP", Success);
  --    end TestCD;
  --




  procedure GetCurrentDirectory
             (Directory : in out string);

  --*
  --  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 -
  --
  --    with DiskLib;
  --
  --    procedure TestGetDir is
  --      MyDir : DiskLib.DirectoryType;
  --    begin
  --      DiskLib.GetCurrentDirectory(MyDir);
  --    end TestGetDir;
  --




  procedure FindFirstMatch
             (Search    : in     string;
              Normal    : in     boolean;
              ReadOnly  : in     boolean;
              Hidden    : in     boolean;
              SystemAtt : in     boolean;
              Volume    : in     boolean;
              Directory : in     boolean;
              Archive   : in     boolean;
              DiskRec   : in out DiskRecordType;
              Success   : in out 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,
  --                    SystemAtt  => 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,
  --                    SystemAtt  => 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 : string
  --      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
  --
  --    SystemAtt : 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 -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestFF
  --
  --      -- Find a file with read only and hidden attribute
  --
  --    begin
  --      DiskLib.FindFirstMatch (Search     => "*.*",
  --                              Normal     => False,
  --                              ReadOnly   => True,
  --                              Hidden     => True,
  --                              SystemAtt  => False,
  --                              Volume     => False,
  --                              Directory  => False,
  --                              Archive    => False,
  --                              DiskRec    => DiskRecord,
  --                              Success    => Success);
  --
  --      if Success then
  --        TermX.WriteString ("Matching file: " &
  --                              DiskRecord.Full);
  --        TermX.WriteLn;
  --      end if;
  --
  --    end TestFF;
  --




  procedure FindNextMatch
             (DiskRec : in out DiskRecordType;
              Success : in out 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 -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestFN
  --
  --      -- Find a file with read only and hidden attribute
  --
  --    begin
  --      DiskLib.FindFirstMatch (Search     => "*.*",
  --                              Normal     => False,
  --                              ReadOnly   => True,
  --                              Hidden     => True,
  --                              SystemAtt  => False,
  --                              Volume     => False,
  --                              Directory  => False,
  --                              Archive    => False,
  --                              DiskRec    => DiskRecord,
  --                              Success    => Success);
  --
  --      if Success then
  --        while Success loop
  --          TermX.WriteString ("Matching file: " &
  --                                DiskRecord.Full);
  --          TermX.WriteLn;
  --
  --          DiskLib.FindNextMatch (DiskRec    => DiskRecord,
  --                                 Success    => Success);
  --        end loop;
  --      end if;
  --
  --    end TestFN;
  --




  procedure DiskQuery
             (Search         : in     string;
              Normal         : in     boolean;
              ReadOnly       : in     boolean;
              Hidden         : in     boolean;
              SystemAtt      : in     boolean;
              Volume         : in     boolean;
              Directory      : in     boolean;
              Archive        : in     boolean;
              AttribType     : in     QueryType;
              PostLocateProc : in     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 with the following parameters:
  --
  --    DiskQuery (Search     => "TE*.*",
  --               Normal     => False,
  --               ReadOnly   => True,
  --               Hidden     => True,
  --               SystemAtt  => 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
  --  with the following parameters:
  --
  --    DiskQuery (Search     => "TE*.*",
  --               Normal     => False,
  --               ReadOnly   => True,
  --               Hidden     => True,
  --               SystemAtt  => 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 with the read only OR the hidden attribute set.
  --
  --  CALLING SEQUENCE -
  --
  --    DiskQuery ("TE*.*", False, True, True, False, False, False, False,
  --               DiskLib.OrQuery);
  --
  --  ENTRY -
  --
  --    Search : string
  --      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
  --
  --    SystemAtt : 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 -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestQ is
  --
  --      -- Find all files with 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) is
  --      begin
  --        TermX.WriteString ("Matching file: " &
  --                           DiskRecord.Full);
  --        TermX.WriteLn;
  --        ContinueOn := TRUE;
  --      end PostLocateProc;
  --
  --
  --    begin
  --      MyQuery (Search     => "*.*",
  --               Normal     => False,
  --               ReadOnly   => True,
  --               Hidden     => True,
  --               SystemAtt  => False,
  --               Volume     => False,
  --               Directory  => False,
  --               Archive    => False,
  --               AttribType => OrQuery);
  --    end TestQ;
  --




  procedure Backup
             (Source          : in     string;
              DestDrive       : in     string;
              DiskRequestProc : in     DiskRequestProcType;
              FileBackupProc  : in     FileBackupProcType);

  --*
  --  Backup - Backup files across multiple diskettes.
  --
  --
  --  This procedure will perform the same function as the MS-DOS 5.0 BACKUP
  --  command.  Files generated by this procedure are fully compatible with
  --  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 with 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 ContinueOn 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 ContinueOn flag to false to abort the entire backup.
  --
  --  CALLING SEQUENCE -
  --
  --    MyBackup (Source, DestDrive);
  --
  --  ENTRY -
  --
  --    Source : string
  --      The name of the files to backup (wild cards/directories allowed)
  --
  --    DestDrive : DriveType
  --      The destination drive identifier i.e. A, B, etc.
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestBU is
  --
  --      InputStr : String(1..1);
  --
  --      procedure DiskRequestProc
  --                 (DiskNumber : in     Modsys.S_Natural;
  --                  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.S_Natural;
  --                  ContinueOn : in out Boolean) is
  --      begin
  --        TermX.WriteString("Enter diskette # " &
  --                             Modsys.S_Natural'image(DiskNumber) &
  --                             " and press enter to continue");
  --        TermX.ReadString(InputStr);
  --        TermX.WriteLn;
  --        ContinueOn := TRUE;
  --      end DiskRequestProc;
  --
  --
  --      procedure FileBackupProc
  --                 (FileName   : in     FullType;
  --                  ContinueOn : in out Boolean);
  --      begin
  --        TermX.WriteString("BACKING UP " & FileName);
  --        TermX.WriteLn;
  --        ContinueOn := TRUE;
  --      end FileBackupProc;
  --
  --
  --    begin
  --      MyBackup("*.*","B:");
  --    end TestBU;
  --




  procedure Restore
             (SourceDrive     : in     string;
              Dest            : in     string;
              DiskRequestProc : in     DiskRequestProcType;
              FileRestoreProc : in     FileRestoreProcType);

  --*
  --  Restore - Restore files from a backup (see DiskLib.Backup).
  --
  --
  --  This procedure will perform the same function 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 with 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 ContinueOn 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 ContinueOn flag to false to abort
  --  the entire restore.
  --
  --  CALLING SEQUENCE -
  --
  --    MyRestore (SourceDrive, Dest);
  --
  --  ENTRY -
  --
  --    SourceDrive : DriveType
  --      The source drive identifier i.e. A, B, etc.
  --
  --    Dest : String
  --      The name of the files to restore (wild cards/directories allowed)
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestRES is
  --
  --      InputStr : String(1..1);
  --
  --      procedure DiskRequestProc
  --                 (DiskNumber : in     Modsys.S_Natural;
  --                  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.S_Natural;
  --                  ContinueOn : in out Boolean) is
  --      begin
  --        TermX.WriteString("Enter diskette # " &
  --                             Modsys.S_Natural'image(DiskNumber) &
  --                             " and press enter to continue");
  --        TermX.ReadString(InputStr);
  --        TermX.WriteLn;
  --        ContinueOn := TRUE;
  --      end DiskRequestProc;
  --
  --      procedure FileRestoreProc
  --                 (FileName   : in     FullType;
  --                  ContinueOn : in out Boolean);
  --      begin
  --        TermX.WriteString("RESTORING UP " & FileName);
  --        TermX.WriteLn;
  --        ContinueOn := TRUE;
  --      end FileRestoreProc;
  --
  --    begin
  --      MyRestore("B:","C:\*.*");
  --    end TestRES;
  --




  procedure GetFileInformation
             (File          : in     string;
              FileSize      :    out ModSys.S_Natural;
              FileAttribute :    out ModSys.S_Natural;
              FileTime      :    out ModSys.S_Integer;
              FileDate      :    out ModSys.S_Integer;
              Success       :    out boolean);

  --*
  --  GetFileInformation - return information about a file.
  --
  --
  --  This procedure will return internal DOS file information
  --
  --  CALLING SEQUENCE -
  --
  --    GetFileInformation (FileName, FileSize, FileAttr,
  --                        FileTime, FileDate, Success);
  --
  --  ENTRY -
  --
  --    FileName : string
  --      The name of the file
  --
  --  EXIT -
  --
  --    FileSize : Modsys.S_Natural
  --      The size of file in bytes
  --
  --    FileAttr : Modsys.S_Natural
  --      The attribute of the file
  --
  --    FileTime : ModSys.S_Integer
  --      The DOS packed file time
  --
  --    FileDate : ModSys.S_Integer
  --      The DOS packed file date
  --
  --    Success : boolean
  --      True - Operation worked.
  --      False - Operation failed.
  --




  procedure PackedDateToDate
             (PackedDate : in     ModSys.S_Integer;
              Year       : in out ModSys.S_Natural;
              Month      : in out ModSys.S_Natural;
              Day        : in out ModSys.S_Natural);

  --*
  --  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.S_Integer
  --      The packed date value
  --
  --  EXIT -
  --
  --    Year : Modsys.S_Natural
  --      The Year (0-9999)
  --
  --    Month : Modsys.S_Natural
  --      The Month (1-12)
  --
  --    Day : Modsys.S_Natural
  --      The day (1-31)
  --




  procedure PackedTimeToTime
             (PackedTime : in     ModSys.S_Integer;
              Hour       : in out ModSys.S_Natural;
              Minute     : in out ModSys.S_Natural;
              Second     : in out ModSys.S_Natural);

  --*
  --  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.S_Integer
  --      The packed time value
  --
  --  EXIT -
  --
  --    Hour : Modsys.S_Natural
  --      The hour (0-23)
  --
  --    Minute : Modsys.S_Natural
  --      The hour (0-59)
  --
  --    Second : Modsys.S_Natural
  --      The second (0-59)
  --




  procedure DirectoryQuery
             (StartPath     : in out string;
              DirectoryProc : in     DirectoryProcType);

  --*
  --  DirectoryQuery - This routine will perform a directory traversal.
  --
  --
  --  This procedure will traverse the directory structure starting with 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 ContinueOn=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 with 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 : string
  --      A valid MS-DOS path with an optional drive
  --
  --  EXIT -
  --
  --    None
  --      N/A
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestDirectoryQuery is
  --
  --      DirectoryName : string(1..76) := (others => ASCIIX.Nul);
  --
  --      procedure Dirq
  --                 (DirName    : in     string;
  --                  ContinueOn : in out boolean);
  --
  --      procedure MyDirectoryQuery is new DiskLib.DirectoryQuery
  --                 (DirQ);
  --
  --      procedure Dirq
  --                 (DirName    : in     string;
  --                  ContinueOn : in out boolean) is
  --      begin
  --        TermX.WriteString (DirName);
  --        TermX.WriteLn;
  --      end Dirq;
  --
  --    begin
  --      TermX.WriteLn;
  --      TermX.WriteLn;
  --      TermX.WriteString("Enter Directory to start traversal :");
  --      TermX.ReadString(DirectoryName);
  --      TermX.WriteLn;
  --      TermX.WriteLn;
  --      MyDirectoryQuery(DirectoryName);
  --    end TestDirectoryQuery;
  --




  procedure SetVolumeLabel
             (Drive    : in     string;
              TheLabel : in     string);

  --*
  --  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 : string
  --      The MS-DOS volume label
  --
  --  EXIT -
  --
  --    None
  --      N/A
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --
  --    procedure TestSL is
  --    Begin
  --      DiskLib.SetVolumeLabel("C:","DOS_50_120");
  --    end TestSL;
  --




  procedure GetVolumeLabel
             (Drive    : in     string;
              TheLabel : in out string);

  --*
  --  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 : string
  --      The MS-DOS volume label
  --
  --  EXAMPLE -
  --
  --    with DiskLib;
  --    with TermX;
  --
  --    procedure TestGL is
  --      Label : string(1..11) := (others => ' ');
  --    Begin
  --      DiskLib.GetVolumeLabel("C:",Label);
  --      TermX.WriteString("VOLUME LABEL IS " & Label);
  --      TermX.WriteLn;
  --    end TestGL;
  --




  procedure FormatFloppyDrive
             (Hwnd         : in     WinSys.Hwnd;
              Drive        : in     string;
              DefaultQuick : in     boolean;
              Success      :    out 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: WinSys.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 : string
  --      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 -
  --
  --    with DiskLib;
  --
  --    procedure TestFormat is
  --
  --      Success : boolean := False;
  --
  --    begin
  --      DiskLib.FormatFloppyDrive ("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