--- oup/current/DataAccess/Access_OniArchive.pas 2007/02/21 03:12:33 109 +++ oup/current/DataAccess/Access_OniArchive.pas 2007/02/26 22:57:02 116 @@ -33,6 +33,8 @@ type procedure LoadDatFilePart(FileID, Offset, Size: Integer; var Target: TStream); overload; override; procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TStream); overload; override; + function GetDatLinks(FileID: Integer): TDatLinkList; override; + function GetDatLink(FileID, DatOffset: Integer): TDatLink; override; function GetRawList(FileID: Integer): TRawDataList; override; function GetRawInfo(FileID, DatOffset: Integer): TRawDataInfo; override; @@ -49,7 +51,7 @@ type implementation uses - SysUtils, StrUtils, Data, Functions, RawList; + SysUtils, StrUtils, Data, Functions, RawList, DatLinks; (* @@ -59,41 +61,6 @@ uses constructor TAccess_OniArchive.Create(DatFilename: String; ConnectionID: Integer; var Msg: TStatusMessages); -type - THeader = packed record - Ident: array[0..$13] of Byte; - Files: Integer; - NamedFiles: Integer; - Extensions: Integer; - DataAddr: Integer; - DataSize: Integer; - NamesAddr: Integer; - NamesSize: Integer; - Ident2: array[0..$F] of Byte; - end; - TFilesMap = array of packed record - Extension: array[0..$3] of Char; - DataAddr: Integer; - NameAddr: Integer; - FileSize: Integer; - FileType: LongWord; - end; - TNamedFilesMap = array of packed record - FileNumber: Integer; - blubb: Integer; - end; -const - header_ident1_pc: array[0..$13] of Byte = - ($1F, $27, $DC, $33, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00, - $14, $00, $10, $00, $08, $00); - header_ident1_mac: array[0..$13] of Byte = - ($61, $30, $C1, $23, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00, - $14, $00, $10, $00, $08, $00); - header_ident1_macbeta: array[0..$13] of Byte = - ($81, $11, $8D, $23, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00, - $14, $00, $10, $00, $08, $00); - header_ident2: array[0..$F] of Byte = - ($99, $CF, $40, $00, $90, $4F, $63, $00, $F4, $55, $5F, $00, $90, $4F, $63, $00); var i: Integer; header_pc, header_mac, header_macbeta: Boolean; @@ -116,14 +83,20 @@ begin header_pc := True; header_mac := True; header_macbeta := True; - for i := 0 to High(Fdat_header.Ident) do + for i := 0 to High(Fdat_header.GlobalIdent) do + if Fdat_header.GlobalIdent[i] <> HeaderGlobalIdent[i] then + begin + Msg := SM_IncompatibleFile; + Exit; + end; + + for i := 0 to High(Fdat_header.OSIdent) do begin -// FLevelInfo.Ident[i] := Fdat_header.Ident[i]; - if Fdat_header.Ident[i] <> header_ident1_pc[i] then + if Fdat_header.OSIdent[i] <> HeaderOSIdentWin[i] then header_pc := False; - if Fdat_header.Ident[i] <> header_ident1_mac[i] then + if Fdat_header.OSIdent[i] <> HeaderOSIdentMac[i] then header_mac := False; - if Fdat_header.Ident[i] <> header_ident1_macbeta[i] then + if Fdat_header.OSIdent[i] <> HeaderOSIdentMacBeta[i] then header_macbeta := False; end; if not (header_pc xor header_mac xor header_macbeta) then @@ -249,6 +222,12 @@ var name := fields.Strings[2]; extension := fields.Strings[0]; end; + if SortType in [ST_ExtNameAsc, ST_ExtNameDesc] then + begin + id := fields.Strings[2]; + name := fields.Strings[1]; + extension := fields.Strings[0]; + end; end; begin @@ -262,10 +241,7 @@ begin begin if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then begin - if AppSettings.FilenumbersAsHex then - id := IntToHex(Fdat_files[i].ID, 4) - else - id := FormatNumber(Fdat_files[i].ID, 5, '0'); + id := FormatNumber(Fdat_files[i].ID, 5, '0'); name := Fdat_files[i].Name; extension := Fdat_files[i].Extension; @@ -273,15 +249,17 @@ begin ST_IDAsc, ST_IDDesc: list.Add(id + ';' + name + ';' + extension); ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension); ST_ExtAsc, ST_ExtDesc: list.Add(extension + ';' + id + ';' + name); + ST_ExtNameAsc, ST_ExtNameDesc: list.Add(name + ';' + extension + ';' + id); end; end; end; end; - Result := TStringList.Create; + if not Assigned(Result) then + Result := TStringList.Create; if list.Count > 0 then begin fields := TStringList.Create; - if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc] then + if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then for i := 0 to list.Count - 1 do begin getfields; @@ -313,7 +291,10 @@ function TAccess_OniArchive.GetExtension var i: Integer; begin - Result := TStringList.Create; + if not Assigned(Result) then + Result := TStringList.Create; + if Result is TStringList then + TStringList(Result).Sorted := True; for i := 0 to Length(Fdat_extensionsmap) - 1 do begin with Fdat_extensionsmap[i] do @@ -417,6 +398,39 @@ end; +function TAccess_OniArchive.GetDatLink(FileID, DatOffset: Integer): TDatLink; +var + link: Integer; +begin + Result := DatLinksManager.GetDatLink(FConnectionID, FileID, DatOffset); + LoadDatFilePart(fileid, Result.SrcOffset, 4, @link); + if link > 0 then + Result.DestID := link div 256 + else + Result.DestID := -1; +end; + + +function TAccess_OniArchive.GetDatLinks(FileID: Integer): TDatLinkList; +var + i: Integer; + link: Integer; +begin + Result := DatLinksManager.GetDatLinks(FConnectionID, FileID); + if Length(Result) > 0 then + begin + for i := 0 to High(Result) do + begin + LoadDatFilePart(fileid, Result[i].SrcOffset, 4, @link); + if link > 0 then + Result[i].DestID := link div 256 + else + Result[i].DestID := -1; + end; + end; +end; + + function TAccess_OniArchive.GetRawList(FileID: Integer): TRawDataList; begin Result := RawLists.GetRawList(FConnectionID, FileID);