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

Comparing:
oup/rewrite/DataAccess/Access_OUP_ADB.pas (file contents), Revision 106 by alloc, Wed Feb 21 03:09:30 2007 UTC vs.
oup/current/DataAccess/Access_OUP_ADB.pas (file contents), Revision 119 by alloc, Fri Mar 23 00:58:41 2007 UTC

# Line 18 | Line 18 | type
18      procedure UpdateListCache;
19  
20      function GetLinksToFile(FileID: Integer): TLinks;
21    function GetLinksFromFile(FileID: Integer): TLinks;
21  
22      function GetFileInfo(FileID: Integer): TFileInfo; override;
23      function GetFilesList(Ext: String; Pattern: String;
# Line 31 | Line 30 | type
30      procedure LoadDatFilePart(FileID, Offset, Size: Integer; var Target: TStream); overload; override;
31      procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TStream); overload; override;
32  
33 +    function GetDatLinks(FileID: Integer): TDatLinkList; override;
34 +    function GetDatLink(FileID, DatOffset: Integer): TDatLink; override;
35      function GetRawList(FileID: Integer): TRawDataList; override;
36      function GetRawInfo(FileID, DatOffset: Integer): TRawDataInfo; override;
37  
# Line 45 | Line 46 | type
46   implementation
47  
48   uses
49 <  SysUtils, Data, Functions, ABSDecUtil, DB;
49 >  SysUtils, Data, Functions, ABSDecUtil, DB, DatLinks;
50  
51  
52   (*
# Line 55 | Line 56 | uses
56  
57  
58   constructor TAccess_OUP_ADB.Create(DBFilename: String; ConnectionID: Integer; var Msg: TStatusMessages);
58 var
59  i: Integer;
59   begin
60    Msg := SM_UnknownError;
61    if not FileExists(DBFilename) then
# Line 141 | Line 140 | begin
140        Fdat_files[i].Name := FQuery.FieldByName('name').AsString;
141        Fdat_files[i].Extension := FQuery.FieldByName('extension').AsString;
142        Fdat_files[i].Size := FQuery.FieldByName('size').AsInteger;
143 <      Fdat_files[i].FileType := HexToLong(FQuery.FieldByName('contenttype').AsString);
143 >      Fdat_files[i].FileType := StrToInt('$'+FQuery.FieldByName('contenttype').AsString);
144        Fdat_files[i].DatAddr := 0;
145        Inc(i);
146        FQuery.Next;
# Line 193 | Line 192 | begin
192    FQuery.Close;
193   end;
194  
196 function TAccess_OUP_ADB.GetLinksFromFile(FileID: Integer): TLinks;
197 var
198  i: Integer;
199 begin
200  SetLength(Result.ByName, 0);
201  FQuery.SQL.Text := 'SELECT src_link_offset, target_id FROM linkmap WHERE src_id = ' + IntToStr(FileID) + ' ORDER BY target_id ASC;';
202  FQuery.Open;
203  SetLength(Result.ByID, FQuery.RecordCount);
204  if FQuery.RecordCount > 0 then
205  begin
206    i := 0;
207    repeat
208      Result.ByID[i].SrcOffset := FQuery.FieldByName('src_link_offset').AsInteger;
209      Result.ByID[i].Destination := FQuery.FieldByName('target_id').AsInteger;
210      Inc(i);
211      FQuery.Next;
212    until FQuery.EOF;
213  end;
214  FQuery.Close;
215 end;
216
195  
196  
197   function TAccess_OUP_ADB.GetFileInfo(fileid: Integer): TFileInfo;
# Line 261 | Line 239 | var
239        name := fields.Strings[2];
240        extension := fields.Strings[0];
241      end;
242 +    if SortType in [ST_ExtNameAsc, ST_ExtNameDesc] then
243 +    begin
244 +      id := fields.Strings[2];
245 +      name := fields.Strings[1];
246 +      extension := fields.Strings[0];
247 +    end;
248    end;
249  
250   begin
# Line 274 | Line 258 | begin
258      begin
259        if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then
260        begin
261 <        if AppSettings.FilenumbersAsHex then
278 <          id := IntToHex(Fdat_files[i].ID, 4)
279 <        else
280 <          id := FormatNumber(Fdat_files[i].ID, 5, '0');
261 >        id := FormatNumber(Fdat_files[i].ID, 5, '0');
262          name := Fdat_files[i].Name;
263          extension := Fdat_files[i].Extension;
264  
# Line 285 | Line 266 | begin
266            ST_IDAsc, ST_IDDesc:     list.Add(id + ';' + name + ';' + extension);
267            ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension);
268            ST_ExtAsc, ST_ExtDesc:   list.Add(extension + ';' + id + ';' + name);
269 +          ST_ExtNameAsc, ST_ExtNameDesc: list.Add(name + ';' + extension + ';' + id);
270          end;
271        end;
272      end;
273    end;
274 <  Result := TStringList.Create;
274 >  if not Assigned(Result) then
275 >    Result := TStringList.Create;
276    if list.Count > 0 then
277    begin
278      fields := TStringList.Create;
279 <    if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc] then
279 >    if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then
280        for i := 0 to list.Count - 1 do
281        begin
282          getfields;
# Line 323 | Line 306 | function TAccess_OUP_ADB.GetExtensionsLi
306   var
307    i: Integer;
308   begin
309 <  Result := TStringList.Create;
309 >  if not Assigned(Result) then
310 >    Result := TStringList.Create;
311 >  if Result is TStringList then
312 >    TStringList(Result).Sorted := True;
313    for i := 0 to Length(Fdat_extensionsmap) - 1 do
314    begin
315      with Fdat_extensionsmap[i] do
# Line 436 | Line 422 | begin
422    end;
423   end;
424  
425 +
426 +
427 + function TAccess_OUP_ADB.GetDatLink(FileID, DatOffset: Integer): TDatLink;
428 + begin
429 +  Result := DatLinksManager.GetDatLink(FConnectionID, FileID, DatOffset);
430 +  FQuery.SQL.Text := 'SELECT target_id FROM linkmap WHERE src_id = ' + IntToStr(FileID) + ' and src_link_offset = ' + IntToStr(DatOffset) + ';';
431 +  FQuery.Open;
432 +  if FQuery.RecordCount > 0 then
433 +    Result.DestID := FQuery.FieldByName('target_id').AsInteger;
434 +  FQuery.Close;
435 + end;
436 +
437 +
438 + function TAccess_OUP_ADB.GetDatLinks(FileID: Integer): TDatLinkList;
439 + var
440 +  i: Integer;
441 +  SrcOffset, DestID: Integer;
442 + begin
443 +  Result := DatLinksManager.GetDatLinks(FConnectionID, FileID);
444 +  if Length(Result) > 0 then
445 +  begin
446 +    FQuery.SQL.Text := 'SELECT src_link_offset, target_id FROM linkmap WHERE src_id = ' + IntToStr(FileID) + ' ORDER BY src_link_offset ASC;';
447 +    FQuery.Open;
448 +    if FQuery.RecordCount > 0 then
449 +    begin
450 +      repeat
451 +        SrcOffset := FQuery.FieldByName('src_link_offset').AsInteger;
452 +        DestID := FQuery.FieldByName('target_id').AsInteger;
453 +        for i := 0 to High(Result) do
454 +          if Result[i].SrcOffset = SrcOffset then
455 +            Break;
456 +        if i < Length(Result) then
457 +          Result[i].DestID := DestID
458 +        else
459 +          Result[i].DestID := -1;
460 +        FQuery.Next;
461 +      until FQuery.EOF;
462 +    end;
463 +    FQuery.Close;
464 +  end;
465 + end;
466 +
467  
468   function TAccess_OUP_ADB.GetRawList(FileID: Integer): TRawDataList;
469   var

Diff Legend

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