ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/DataAccess/Access_OniArchive.pas
(Generate patch)

Comparing:
oup/rewrite/DataAccess/Access_OniArchive.pas (file contents), Revision 101 by alloc, Tue Feb 20 20:43:29 2007 UTC vs.
oup/current/DataAccess/Access_OniArchive.pas (file contents), Revision 113 by alloc, Sun Feb 25 17:20:22 2007 UTC

# Line 33 | Line 33 | type
33      procedure LoadDatFilePart(FileID, Offset, Size: Integer; var Target: TStream); overload; override;
34      procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TStream); overload; override;
35  
36 +    function GetDatLinks(FileID: Integer): TDatLinkList; override;
37      function GetRawList(FileID: Integer): TRawDataList; override;
38      function GetRawInfo(FileID, DatOffset: Integer): TRawDataInfo; override;
39  
# Line 42 | Line 43 | type
43      procedure LoadRawFilePart(FileID, DatOffset, Offset, Size: Integer; var Target: TStream); overload; override;
44      procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TStream); overload; override;
45  
46 <    function AppendRawFile(LocSep: Boolean; Size: Integer; Src: TStream): Integer; overload; override;
46 >    function AppendRawFile(LocSep: Boolean; Src: TStream): Integer; overload; override;
47    published
48    end;
49  
# Line 59 | Line 60 | uses
60  
61  
62   constructor TAccess_OniArchive.Create(DatFilename: String; ConnectionID: Integer; var Msg: TStatusMessages);
62 type
63  THeader = packed record
64    Ident:      array[0..$13] of Byte;
65    Files:      Integer;
66    NamedFiles: Integer;
67    Extensions: Integer;
68    DataAddr:   Integer;
69    DataSize:   Integer;
70    NamesAddr:  Integer;
71    NamesSize:  Integer;
72    Ident2:     array[0..$F] of Byte;
73  end;
74  TFilesMap = array of packed record
75    Extension: array[0..$3] of Char;
76    DataAddr:  Integer;
77    NameAddr:  Integer;
78    FileSize:  Integer;
79    FileType:  LongWord;
80  end;
81  TNamedFilesMap = array of packed record
82    FileNumber: Integer;
83    blubb:      Integer;
84  end;
85 const
86  header_ident1_pc: array[0..$13] of Byte =
87    ($1F, $27, $DC, $33, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
88    $14, $00, $10, $00, $08, $00);
89  header_ident1_mac: array[0..$13] of Byte =
90    ($61, $30, $C1, $23, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
91    $14, $00, $10, $00, $08, $00);
92  header_ident1_macbeta: array[0..$13] of Byte =
93    ($81, $11, $8D, $23, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
94    $14, $00, $10, $00, $08, $00);
95  header_ident2: array[0..$F] of Byte =
96    ($99, $CF, $40, $00, $90, $4F, $63, $00, $F4, $55, $5F, $00, $90, $4F, $63, $00);
63   var
64    i: Integer;
65    header_pc, header_mac, header_macbeta: Boolean;
# Line 116 | Line 82 | begin
82    header_pc  := True;
83    header_mac := True;
84    header_macbeta := True;
85 <  for i := 0 to High(Fdat_header.Ident) do
85 >  for i := 0 to High(Fdat_header.GlobalIdent) do
86 >    if Fdat_header.GlobalIdent[i] <> HeaderGlobalIdent[i] then
87 >    begin
88 >      Msg := SM_IncompatibleFile;
89 >      Exit;
90 >    end;
91 >
92 >  for i := 0 to High(Fdat_header.OSIdent) do
93    begin
94 < //    FLevelInfo.Ident[i] := Fdat_header.Ident[i];
122 <    if Fdat_header.Ident[i] <> header_ident1_pc[i] then
94 >    if Fdat_header.OSIdent[i] <> HeaderOSIdentWin[i] then
95        header_pc := False;
96 <    if Fdat_header.Ident[i] <> header_ident1_mac[i] then
96 >    if Fdat_header.OSIdent[i] <> HeaderOSIdentMac[i] then
97        header_mac := False;
98 <    if Fdat_header.Ident[i] <> header_ident1_macbeta[i] then
98 >    if Fdat_header.OSIdent[i] <> HeaderOSIdentMacBeta[i] then
99        header_macbeta := False;
100    end;
101    if not (header_pc xor header_mac xor header_macbeta) then
# Line 183 | Line 155 | begin
155  
156    Msg := SM_OK;
157    FBackend := DB_ONI;
158 +  FConnectionID := ConnectionID;
159    FChangeRights := [CR_EditDat, CR_EditRaw, CR_AppendRaw];
160   end;
161  
# Line 248 | Line 221 | var
221        name := fields.Strings[2];
222        extension := fields.Strings[0];
223      end;
224 +    if SortType in [ST_ExtNameAsc, ST_ExtNameDesc] then
225 +    begin
226 +      id := fields.Strings[2];
227 +      name := fields.Strings[1];
228 +      extension := fields.Strings[0];
229 +    end;
230    end;
231  
232   begin
# Line 261 | Line 240 | begin
240      begin
241        if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then
242        begin
243 <        if AppSettings.FilenumbersAsHex then
265 <          id := IntToHex(Fdat_files[i].ID, 4)
266 <        else
267 <          id := FormatNumber(Fdat_files[i].ID, 5, '0');
243 >        id := FormatNumber(Fdat_files[i].ID, 5, '0');
244          name := Fdat_files[i].Name;
245          extension := Fdat_files[i].Extension;
246  
# Line 272 | Line 248 | begin
248            ST_IDAsc, ST_IDDesc:     list.Add(id + ';' + name + ';' + extension);
249            ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension);
250            ST_ExtAsc, ST_ExtDesc:   list.Add(extension + ';' + id + ';' + name);
251 +          ST_ExtNameAsc, ST_ExtNameDesc: list.Add(name + ';' + extension + ';' + id);
252          end;
253        end;
254      end;
255    end;
256 <  Result := TStringList.Create;
256 >  if not Assigned(Result) then
257 >    Result := TStringList.Create;
258    if list.Count > 0 then
259    begin
260      fields := TStringList.Create;
261 <    if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc] then
261 >    if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then
262        for i := 0 to list.Count - 1 do
263        begin
264          getfields;
# Line 312 | Line 290 | function TAccess_OniArchive.GetExtension
290   var
291    i: Integer;
292   begin
293 <  Result := TStringList.Create;
293 >  if not Assigned(Result) then
294 >    Result := TStringList.Create;
295 >  if Result is TStringList then
296 >    TStringList(Result).Sorted := True;
297    for i := 0 to Length(Fdat_extensionsmap) - 1 do
298    begin
299      with Fdat_extensionsmap[i] do
# Line 615 | Line 596 | begin
596    end;
597   end;
598  
599 < function TAccess_OniArchive.AppendRawFile(LocSep: Boolean; Size: Integer; Src: TStream): Integer;
599 > function TAccess_OniArchive.AppendRawFile(LocSep: Boolean; Src: TStream): Integer;
600   begin
601    if not LocSep then
602    begin
# Line 624 | Line 605 | begin
605          fmOpenReadWrite);
606      Result := Fraw_file.Size;
607      Fraw_file.Seek(0, soFromEnd);
608 <    Fraw_file.CopyFrom(Src, Size);
608 >    Fraw_file.CopyFrom(Src, Src.Size);
609      if UnloadWhenUnused then
610      begin
611        FRawOpened := False;
# Line 640 | Line 621 | begin
621          fmOpenReadWrite);
622      Result := Fsep_file.Size;
623      Fsep_file.Seek(0, soFromEnd);
624 <    Fsep_file.CopyFrom(Src, Size);
624 >    Fsep_file.CopyFrom(Src, Src.Size);
625      if UnloadWhenUnused then
626      begin
627        FSepOpened := False;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)