ISO9660SupplementVolClass.pas
上传用户:wanyu_2000
上传日期:2021-02-21
资源大小:527k
文件大小:13k
源码类别:

DVD

开发平台:

Delphi

  1. {-----------------------------------------------------------------------------
  2.  Unit Name: ISO9660SupplementVolClass
  3.  Author:    Dancemammal, Daniel Mann / Thomas Koos (original class structure)
  4.  Purpose:   Supplementary Volume Descriptor Class
  5.  History:   First Code Release
  6. -----------------------------------------------------------------------------}
  7. Unit ISO9660SupplementVolClass;
  8. Interface
  9. Uses
  10.   SysUtils,
  11.   windows,
  12.   Classes,
  13.   CovertFuncs,
  14.   ISO9660ClassTypes;
  15. Type
  16.   TSupplementaryVolumeDescriptor = Class
  17.   Private
  18.     Function  GetString(Const AIndex : Integer): String;
  19.     Procedure SetString(const AIndex : Integer; Const Value: String);
  20.     Procedure SetVolumeIdentifier(Const Value: String);
  21.     Function  GetVolumeIdentifier : String;
  22.     Function  Getwide(ID : Array of Char) : String;
  23.   Protected
  24.     FDescriptor : TVolumeDescriptor;
  25.     FRootDirectoryRecord : TRootDirectoryRecord;
  26.     LastErrorString : String;
  27.   Public
  28.     Constructor Create; Overload; Virtual;
  29.     Constructor Create(Const ASupplementaryVolumeDescriptor : TVolumeDescriptor); Overload; Virtual;
  30.     Destructor  Destroy; Override;
  31.     Procedure ResetRootExtent(SUPPRootLBA : Integer);
  32.     Function GetLastError : String;
  33.   Published
  34.     Property  Descriptor : TVolumeDescriptor  Read  fDescriptor;
  35.     Property  SystemIdentifier            : String   Index 0  Read  GetString Write SetString;
  36.     Property  VolumeIdentifier            : String            Read  GetVolumeIdentifier Write SetVolumeIdentifier;
  37.     Property  VolumeSetIdentifier         : String   Index 2  Read  GetString Write SetString;
  38.     Property  PublisherIdentifier         : String   Index 3  Read  GetString Write SetString;
  39.     Property  DataPreparerIdentifier      : String   Index 4  Read  GetString Write SetString;
  40.     Property  ApplicationIdentifier       : String   Index 5  Read  GetString Write SetString;
  41.     Property  CopyrightFileIdentifier     : String   Index 6  Read  GetString Write SetString;
  42.     Property  AbstractFileIdentifier      : String   Index 7  Read  GetString Write SetString;
  43.     Property  BibliographicFileIdentifier : String   Index 8  Read  GetString Write SetString;
  44.     Property  VolumeCreationDateAndTime   : TVolumeDateTime   Read  fDescriptor.Supplementary.VolumeCreationDateAndTime
  45.                                                               Write fDescriptor.Supplementary.VolumeCreationDateAndTime;
  46.     Property  VolumeModificationDateAndTime : TVolumeDateTime
  47.                                                               Read  fDescriptor.Supplementary.VolumeModificationDateAndTime
  48.                                                               Write fDescriptor.Supplementary.VolumeModificationDateAndTime;
  49.     Property  VolumeExpirationDateAndTime : TVolumeDateTime   Read  fDescriptor.Supplementary.VolumeExpirationDateAndTime
  50.                                                               Write fDescriptor.Supplementary.VolumeExpirationDateAndTime;
  51.     Property  VolumeEffectiveDateAndTime  : TVolumeDateTime   Read  fDescriptor.Supplementary.VolumeEffectiveDateAndTime
  52.                                                               Write fDescriptor.Supplementary.VolumeEffectiveDateAndTime;
  53.     Property  VolumeSetSize               : TBothEndianWord   Read  fDescriptor.Supplementary.VolumeSetSize
  54.                                                               Write fDescriptor.Supplementary.VolumeSetSize;
  55.     Property  VolumeSequenceNumber        : TBothEndianWord   Read  fDescriptor.Supplementary.VolumeSequenceNumber
  56.                                                               Write fDescriptor.Supplementary.VolumeSequenceNumber;
  57.     Property  LogicalBlockSize            : TBothEndianWord   Read  fDescriptor.Supplementary.LogicalBlockSize
  58.                                                               Write fDescriptor.Supplementary.LogicalBlockSize;
  59.     Property  PathTableSize               : TBothEndianDWord  Read  fDescriptor.Supplementary.PathTableSize
  60.                                                               Write fDescriptor.Supplementary.PathTableSize;
  61.     Property  VolumeSpaceSize             : TBothEndianDWord  Read  fDescriptor.Supplementary.VolumeSpaceSize
  62.                                                               Write fDescriptor.Supplementary.VolumeSpaceSize;
  63.     Property  RootDirectory               : TRootDirectoryRecord
  64.                                                               Read  fDescriptor.Supplementary.RootDirectory
  65.                                                               Write fDescriptor.Supplementary.RootDirectory;
  66.     Property  LocationOfTypeLPathTable    : LongWord          Read  fDescriptor.Supplementary.LocationOfTypeLPathTable
  67.                                                               Write fDescriptor.Supplementary.LocationOfTypeLPathTable;
  68.     Property  LocationOfOptionalTypeLPathTable : LongWord     Read  fDescriptor.Supplementary.LocationOfOptionalTypeLPathTable
  69.                                                               Write fDescriptor.Supplementary.LocationOfOptionalTypeLPathTable;
  70.     Property  LocationOfTypeMPathTable    : LongWord          Read  fDescriptor.Supplementary.LocationOfTypeMPathTable
  71.                                                               Write fDescriptor.Supplementary.LocationOfTypeMPathTable;
  72.     Property  LocationOfOptionalTypeMPathTable : LongWord     Read  fDescriptor.Supplementary.LocationOfOptionalTypeMPathTable
  73.                                                               Write fDescriptor.Supplementary.LocationOfOptionalTypeMPathTable;
  74.     Property  VolumeFlags                      : Byte         Read  fDescriptor.Supplementary.VolumeFlags
  75.                                                               Write fDescriptor.Supplementary.VolumeFlags;
  76.   End;
  77. Implementation
  78. Constructor TSupplementaryVolumeDescriptor.Create; // New Widestring Functions
  79. var
  80.      Temp : String;
  81.      WideChr : PWideChar;
  82. Begin
  83.   Inherited Create;
  84.   FillChar(fDescriptor, SizeOf(fDescriptor), 0);
  85.   fDescriptor.DescriptorType := vdtSVD;
  86.   WideChr := 'WIN32';
  87.   FillChar(FDescriptor.Supplementary.SystemIdentifier,32,0);
  88.   CopyMemory(@FDescriptor.Supplementary.SystemIdentifier[1],@WideChr[0],(length('WIN32')*2)-1);//makes it big endian wide char
  89.   FDescriptor.Supplementary.StandardIdentifier      := ISO_STANDARD_ID;
  90.   FDescriptor.Supplementary.VolumeDescriptorVersion := 1;
  91.   FDescriptor.Supplementary.VolumeSetSize           := BuildBothEndianWord(1);
  92.   FDescriptor.Supplementary.FileStructureVersion    := $01;
  93.   FillChar(FDescriptor.Supplementary.PublisherIdentifier,length(FDescriptor.Supplementary.PublisherIdentifier),$20);
  94.   FillChar(FDescriptor.Supplementary.DataPreparerIdentifier,length(FDescriptor.Supplementary.DataPreparerIdentifier),$20);
  95.   FillChar(FDescriptor.Supplementary.PublisherIdentifier,length(FDescriptor.Supplementary.PublisherIdentifier),$20);
  96.   FillChar(FDescriptor.Supplementary.VolumeSetIdentifier,length(FDescriptor.Supplementary.VolumeSetIdentifier),$20);
  97.   FDescriptor.Supplementary.VolumeCreationDateAndTime := BuildVolumeDateTime(NOW,0);
  98.   FDescriptor.Supplementary.VolumeModificationDateAndTime := BuildVolumeDateTime(NOW,0);
  99.   FDescriptor.Supplementary.LogicalBlockSize              := BuildBothEndianWord(2048);
  100.   FDescriptor.Supplementary.VolumeSequenceNumber          := BuildBothEndianWord(1);
  101.   FDescriptor.Supplementary.LocationOfTypeLPathTable      := 21;
  102.   FDescriptor.Supplementary.LocationOfOptionalTypeLPathTable := 0;
  103.   FDescriptor.Supplementary.LocationOfTypeMPathTable      := SwapDWord(22);
  104.   FDescriptor.Supplementary.LocationOfOptionalTypeMPathTable := 0;
  105.   FillChar(FDescriptor.Supplementary.EscapeSequences,32,0);
  106.   FDescriptor.Supplementary.EscapeSequences[0] := '%';
  107.   FDescriptor.Supplementary.EscapeSequences[1] := '/';
  108.   FDescriptor.Supplementary.EscapeSequences[2] := 'E';
  109.   Temp := FormatDateTime('yyyymmddhhnnsszz',Now);
  110.  // WideChr := pwidechar(Temp);
  111.   WideChr := StrToUnicode(Temp);
  112.   FillChar(FDescriptor.Supplementary.VolumeIdentifier,32,0);
  113.   CopyMemory(@FDescriptor.Supplementary.VolumeIdentifier[1],@WideChr[0],(length(Temp)*2)-1);//makes it big endian wide char
  114.   WideChr := StrToUnicode(ISO_LIBRARY_ID);
  115.   FillChar(FDescriptor.Supplementary.ApplicationIdentifier,128,0);
  116.   CopyMemory(@FDescriptor.Supplementary.ApplicationIdentifier[1],@WideChr[0],(length(ISO_LIBRARY_ID)*2)-1);//makes it big endian wide char
  117. End;
  118. Procedure TSupplementaryVolumeDescriptor.ResetRootExtent(SUPPRootLBA : Integer);
  119. begin
  120.     FDescriptor.Supplementary.RootDirectory.LocationOfExtent := BuildBothEndianDWord(SUPPRootLBA);
  121. end;
  122. Constructor TSupplementaryVolumeDescriptor.Create(Const ASupplementaryVolumeDescriptor: TVolumeDescriptor);
  123. Begin
  124.   Inherited Create;
  125.   If ( ASupplementaryVolumeDescriptor.DescriptorType <> vdtSVD ) Then
  126.     LastErrorString :=('MisMatched Primary Volume Descriptor');
  127.   fDescriptor := ASupplementaryVolumeDescriptor;
  128. End;
  129. Destructor TSupplementaryVolumeDescriptor.Destroy;
  130. Begin
  131.   Inherited;
  132. End;
  133. Function TSupplementaryVolumeDescriptor.GetLastError : String;
  134. begin
  135.     Result := LastErrorString;
  136. end;
  137. Function TSupplementaryVolumeDescriptor.Getwide(ID : Array of Char) : String;
  138. var
  139.   TempStr : String;
  140.   Index : Integer;
  141. begin
  142.    For Index := 0 to length(id) do
  143.    TempStr := TempStr + id[index];
  144.    Result := TempStr;
  145. end;
  146. Function TSupplementaryVolumeDescriptor.GetString(Const AIndex: Integer): String;
  147. Begin
  148.   Case AIndex Of
  149.     0 : Result := Getwide(fDescriptor.Supplementary.SystemIdentifier);
  150.     1 : Result := Getwide(fDescriptor.Supplementary.VolumeIdentifier);
  151.     2 : Result := Getwide(fDescriptor.Supplementary.VolumeSetIdentifier);
  152.     3 : Result := Getwide(fDescriptor.Supplementary.PublisherIdentifier);
  153.     4 : Result := Getwide(fDescriptor.Supplementary.DataPreparerIdentifier);
  154.     5 : Result := Getwide(fDescriptor.Supplementary.ApplicationIdentifier);
  155.     6 : Result := Getwide(fDescriptor.Supplementary.CopyrightFileIdentifier);
  156.     7 : Result := Getwide(fDescriptor.Supplementary.AbstractFileIdentifier);
  157.     8 : Result := Getwide(fDescriptor.Supplementary.BibliographicFileIdentifier);
  158.     9 : Result := Getwide(fDescriptor.Supplementary.StandardIdentifier);
  159.   End;
  160. End;
  161. Procedure TSupplementaryVolumeDescriptor.SetVolumeIdentifier(Const Value: String);
  162. var
  163.      WideChr : PWideChar;
  164.      Temp : String;
  165.      Size : Integer;
  166. begin
  167.    Temp := Value;
  168.    Size := (length(temp)+1)*2;
  169.    WideChr := PWideChar(StrAlloc(Size));//important
  170.    StringToWideChar(temp,WideChr,Size + 1);
  171.    FillChar(fDescriptor.Supplementary.VolumeIdentifier,32,0);
  172.    CopyMemory(@fDescriptor.Supplementary.VolumeIdentifier[1],@WideChr[0],(length(Temp)*2)-1);//makes it big endian wide char
  173. end;
  174. Function TSupplementaryVolumeDescriptor.GetVolumeIdentifier : String;
  175. var
  176.   TempStr : String;
  177. begin
  178.    TempStr := Getwide(fDescriptor.Supplementary.VolumeIdentifier);
  179.    Result := TempStr;
  180. end;
  181. Procedure TSupplementaryVolumeDescriptor.SetString(Const AIndex: Integer; Const Value: String);
  182. Begin
  183.   Case AIndex Of
  184.     0 : StrPCopy(fDescriptor.Supplementary.SystemIdentifier,
  185.                   Copy(Value, 1, Length(fDescriptor.Supplementary.SystemIdentifier)));
  186.     1 : StrPCopy(fDescriptor.Supplementary.VolumeIdentifier,
  187.                   Copy(Value, 1, Length(fDescriptor.Supplementary.VolumeIdentifier)));
  188.     2 : StrPCopy(fDescriptor.Supplementary.VolumeSetIdentifier,
  189.                   Copy(Value, 1, Length(fDescriptor.Supplementary.VolumeSetIdentifier)));
  190.     3 : StrPCopy(fDescriptor.Supplementary.PublisherIdentifier,
  191.                   Copy(Value, 1, Length(fDescriptor.Supplementary.PublisherIdentifier)));
  192.     4 : StrPCopy(fDescriptor.Supplementary.DataPreparerIdentifier,
  193.                   Copy(Value, 1, Length(fDescriptor.Supplementary.DataPreparerIdentifier)));
  194.     5 : StrPCopy(fDescriptor.Supplementary.ApplicationIdentifier,
  195.                   Copy(Value, 1, Length(fDescriptor.Supplementary.ApplicationIdentifier)));
  196.     6 : StrPCopy(fDescriptor.Supplementary.CopyrightFileIdentifier,
  197.                   Copy(Value, 1, Length(fDescriptor.Supplementary.CopyrightFileIdentifier)));
  198.     7 : StrPCopy(fDescriptor.Supplementary.AbstractFileIdentifier,
  199.                   Copy(Value, 1, Length(fDescriptor.Supplementary.AbstractFileIdentifier)));
  200.     8 : StrPCopy(fDescriptor.Supplementary.BibliographicFileIdentifier,
  201.                   Copy(Value, 1, Length(fDescriptor.Supplementary.BibliographicFileIdentifier)));
  202.     9 : StrPCopy(fDescriptor.Supplementary.StandardIdentifier,
  203.                   Copy(Value, 1, Length(fDescriptor.Supplementary.StandardIdentifier)));
  204.   End;
  205. End;
  206. End.