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 134 by alloc, Wed Mar 28 17:53:54 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 67 | Line 66 | begin
66    FFileName := DBFilename;
67  
68    FDatabase := TABSDatabase.Create(nil);
69 +  FDatabase.Exclusive := True;
70 +  FDatabase.MultiUser := False;
71    FDatabase.DatabaseName := 'OLDBcon' + IntToStr(ConnectionID);
72    FDatabase.DatabaseFileName := DBFilename;
73    FDatabase.Open;
74    FQuery := TABSQuery.Create(FDatabase);
75 +  FQuery.DisableControls;
76    FQuery.DatabaseName := 'OLDBcon' + IntToStr(ConnectionID);
77    FQuery.SQL.Text := 'SELECT [name],[value] FROM globals ORDER BY [name] ASC';
78    FQuery.Open;
# Line 141 | Line 143 | begin
143        Fdat_files[i].Name := FQuery.FieldByName('name').AsString;
144        Fdat_files[i].Extension := FQuery.FieldByName('extension').AsString;
145        Fdat_files[i].Size := FQuery.FieldByName('size').AsInteger;
146 <      Fdat_files[i].FileType := HexToLong(FQuery.FieldByName('contenttype').AsString);
146 >      Fdat_files[i].FileType := StrToInt('$'+FQuery.FieldByName('contenttype').AsString);
147        Fdat_files[i].DatAddr := 0;
148        Inc(i);
149        FQuery.Next;
# Line 193 | Line 195 | begin
195    FQuery.Close;
196   end;
197  
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
198  
199  
200   function TAccess_OUP_ADB.GetFileInfo(fileid: Integer): TFileInfo;
# Line 261 | Line 242 | var
242        name := fields.Strings[2];
243        extension := fields.Strings[0];
244      end;
245 +    if SortType in [ST_ExtNameAsc, ST_ExtNameDesc] then
246 +    begin
247 +      id := fields.Strings[2];
248 +      name := fields.Strings[1];
249 +      extension := fields.Strings[0];
250 +    end;
251    end;
252  
253   begin
# Line 274 | Line 261 | begin
261      begin
262        if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then
263        begin
264 <        if AppSettings.FilenumbersAsHex then
278 <          id := IntToHex(Fdat_files[i].ID, 4)
279 <        else
280 <          id := FormatNumber(Fdat_files[i].ID, 5, '0');
264 >        id := FormatNumber(Fdat_files[i].ID, 5, '0');
265          name := Fdat_files[i].Name;
266          extension := Fdat_files[i].Extension;
267  
# Line 285 | Line 269 | begin
269            ST_IDAsc, ST_IDDesc:     list.Add(id + ';' + name + ';' + extension);
270            ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension);
271            ST_ExtAsc, ST_ExtDesc:   list.Add(extension + ';' + id + ';' + name);
272 +          ST_ExtNameAsc, ST_ExtNameDesc: list.Add(name + ';' + extension + ';' + id);
273          end;
274        end;
275      end;
276    end;
277 <  Result := TStringList.Create;
277 >  if not Assigned(Result) then
278 >    Result := TStringList.Create;
279    if list.Count > 0 then
280    begin
281      fields := TStringList.Create;
282 <    if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc] then
282 >    if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc, ST_ExtNameAsc] then
283        for i := 0 to list.Count - 1 do
284        begin
285          getfields;
# Line 323 | Line 309 | function TAccess_OUP_ADB.GetExtensionsLi
309   var
310    i: Integer;
311   begin
312 <  Result := TStringList.Create;
312 >  if not Assigned(Result) then
313 >    Result := TStringList.Create;
314 >  if Result is TStringList then
315 >    TStringList(Result).Sorted := True;
316    for i := 0 to Length(Fdat_extensionsmap) - 1 do
317    begin
318      with Fdat_extensionsmap[i] do
# Line 436 | Line 425 | begin
425    end;
426   end;
427  
428 +
429 +
430 + function TAccess_OUP_ADB.GetDatLink(FileID, DatOffset: Integer): TDatLink;
431 + begin
432 +  Result := DatLinksManager.GetDatLink(FConnectionID, FileID, DatOffset);
433 +  FQuery.SQL.Text := 'SELECT target_id FROM linkmap WHERE src_id = ' + IntToStr(FileID) + ' and src_link_offset = ' + IntToStr(DatOffset) + ';';
434 +  FQuery.Open;
435 +  if FQuery.RecordCount > 0 then
436 +    Result.DestID := FQuery.FieldByName('target_id').AsInteger;
437 +  FQuery.Close;
438 + end;
439 +
440 +
441 + function TAccess_OUP_ADB.GetDatLinks(FileID: Integer): TDatLinkList;
442 + var
443 +  i: Integer;
444 +  SrcOffset, DestID: Integer;
445 + begin
446 +  Result := DatLinksManager.GetDatLinks(FConnectionID, FileID);
447 +  if Length(Result) > 0 then
448 +  begin
449 +    FQuery.SQL.Text := 'SELECT src_link_offset, target_id FROM linkmap WHERE src_id = ' + IntToStr(FileID) + ' ORDER BY src_link_offset ASC;';
450 +    FQuery.Open;
451 +    if FQuery.RecordCount > 0 then
452 +    begin
453 +      repeat
454 +        SrcOffset := FQuery.FieldByName('src_link_offset').AsInteger;
455 +        DestID := FQuery.FieldByName('target_id').AsInteger;
456 +        for i := 0 to High(Result) do
457 +          if Result[i].SrcOffset = SrcOffset then
458 +            Break;
459 +        if i < Length(Result) then
460 +          Result[i].DestID := DestID
461 +        else
462 +          Result[i].DestID := -1;
463 +        FQuery.Next;
464 +      until FQuery.EOF;
465 +    end;
466 +    FQuery.Close;
467 +  end;
468 + end;
469 +
470  
471   function TAccess_OUP_ADB.GetRawList(FileID: Integer): TRawDataList;
472   var

Diff Legend

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