| 135 |
|
published |
| 136 |
|
end; |
| 137 |
|
|
| 138 |
+ |
TOniDataEmpty = class(TOniData) |
| 139 |
+ |
private |
| 140 |
+ |
protected |
| 141 |
+ |
public |
| 142 |
+ |
constructor Create(OLDBFilename: String; var Result: Boolean); override; |
| 143 |
+ |
procedure Close; override; |
| 144 |
+ |
{ |
| 145 |
+ |
procedure UpdateListCache; |
| 146 |
+ |
// function GetDatLinks(srcid:LongWord):TDatLinks; |
| 147 |
+ |
function GetFileInfo(fileid: LongWord): TFileInfo; override; |
| 148 |
+ |
function GetFilesList(ext: String; pattern: String; |
| 149 |
+ |
NoEmptyFiles: Boolean; sort: TSortType): TStringArray; override; |
| 150 |
+ |
function GetFilesCount: LongWord; override; |
| 151 |
+ |
function GetExtensionsList: TStringArray; override; |
| 152 |
+ |
function GetExtendedExtensionsList: TExtensionsMap; override; |
| 153 |
+ |
function GetNamedFilesMap: TNamedFilesMap; |
| 154 |
+ |
|
| 155 |
+ |
function LoadDatFile(fileid: LongWord): Tdata; override; |
| 156 |
+ |
procedure UpdateDatFile(fileid: LongWord; Data: Tdata); override; |
| 157 |
+ |
procedure LoadDatFilePart(fileid, offset, size: LongWord; target: Pointer); override; |
| 158 |
+ |
procedure UpdateDatFilePart(fileid, offset, size: LongWord; target: Pointer); override; |
| 159 |
+ |
|
| 160 |
+ |
function GetRawList(fileid: LongWord): TRawList; override; |
| 161 |
+ |
procedure LoadRawFile(fileid, dat_offset: LongWord; target: Pointer); override; |
| 162 |
+ |
procedure UpdateRawFile(fileid, dat_offset: LongWord; size: LongWord; |
| 163 |
+ |
target: Pointer); override; |
| 164 |
+ |
procedure LoadRawFilePart(fileid, dat_offset: LongWord; |
| 165 |
+ |
offset, size: LongWord; target: Pointer); override; |
| 166 |
+ |
procedure UpdateRawFilePart(fileid, dat_offset: LongWord; |
| 167 |
+ |
offset, size: LongWord; target: Pointer); override; |
| 168 |
+ |
} published |
| 169 |
+ |
end; |
| 170 |
|
|
| 171 |
|
const |
| 172 |
|
ODB_None = -1; |
| 174 |
|
ODB_ADB = 1; |
| 175 |
|
|
| 176 |
|
var |
| 177 |
+ |
// OniDataConnection: TOniData; |
| 178 |
+ |
DataConnections: array of TOniData; |
| 179 |
|
OniDataConnection: TOniData; |
| 180 |
|
|
| 181 |
< |
function CreateDataConnection(filename: String; backend: Integer): Boolean; |
| 182 |
< |
procedure CloseDataConnection; |
| 181 |
> |
function CreateDataConnection(filename: String; backend: Integer): TOniData; |
| 182 |
> |
procedure CloseDataConnection(connection: TOniData); |
| 183 |
> |
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 1406 |
|
|
| 1407 |
|
|
| 1408 |
|
|
| 1409 |
< |
function CreateDataConnection(filename: String; backend: Integer): Boolean; |
| 1409 |
> |
function CreateDataConnection(filename: String; backend: Integer): TOniData; |
| 1410 |
|
var |
| 1411 |
|
answer: Boolean; |
| 1412 |
+ |
i: Integer; |
| 1413 |
|
begin |
| 1414 |
< |
if Assigned(OniDataConnection) then |
| 1414 |
> |
if Length(DataConnections) > 0 then |
| 1415 |
> |
begin |
| 1416 |
> |
for i := 0 to High(DataConnections) do |
| 1417 |
> |
begin |
| 1418 |
> |
if ExtractFileName(DataConnections[i].FFileName) = ExtractFileName(filename) then |
| 1419 |
> |
begin |
| 1420 |
> |
if DataConnections[i].FFileName <> filename then |
| 1421 |
> |
begin |
| 1422 |
> |
Result := nil; |
| 1423 |
> |
ShowMessage('You can not open two files with the same name at a time.'); |
| 1424 |
> |
end |
| 1425 |
> |
else |
| 1426 |
> |
Result := DataConnections[i]; |
| 1427 |
> |
Exit; |
| 1428 |
> |
end; |
| 1429 |
> |
end; |
| 1430 |
> |
end; |
| 1431 |
> |
|
| 1432 |
> |
if not FileExists(filename) then |
| 1433 |
|
begin |
| 1434 |
< |
OniDataConnection.Close; |
| 1435 |
< |
OniDataConnection.Free; |
| 1436 |
< |
OniDataConnection := nil; |
| 1434 |
> |
ShowMessage('File "' + filename + '" does not exist!'); |
| 1435 |
> |
Result := nil; |
| 1436 |
> |
Exit; |
| 1437 |
|
end; |
| 1438 |
+ |
|
| 1439 |
+ |
SetLength(DataConnections, Length(DataConnections) + 1); |
| 1440 |
+ |
i := High(DataConnections); |
| 1441 |
|
case backend of |
| 1442 |
|
ODB_Dat: |
| 1443 |
< |
OniDataConnection := TOniDataDat.Create(filename, answer); |
| 1443 |
> |
DataConnections[i] := TOniDataDat.Create(filename, answer); |
| 1444 |
|
ODB_ADB: |
| 1445 |
< |
OniDataConnection := TOniDataADB.Create(filename, answer); |
| 1445 |
> |
DataConnections[i] := TOniDataADB.Create(filename, answer); |
| 1446 |
|
else |
| 1447 |
|
ShowMessage('Unknown Backend'); |
| 1448 |
< |
Result := False; |
| 1448 |
> |
Result := nil; |
| 1449 |
|
Exit; |
| 1450 |
|
end; |
| 1451 |
|
|
| 1452 |
|
if answer then |
| 1453 |
|
begin |
| 1454 |
< |
// ShowMessage('file loaded'); |
| 1455 |
< |
// ShowMessage('Files: '+IntToStr(OniDataConnection.GetFilesCount)); |
| 1399 |
< |
Result := True; |
| 1454 |
> |
Result := DataConnections[i]; |
| 1455 |
> |
// Result := True; |
| 1456 |
|
end |
| 1457 |
|
else |
| 1458 |
|
begin |
| 1459 |
|
ShowMessage('File not loaded'); |
| 1460 |
< |
OniDataConnection.Close; |
| 1461 |
< |
OniDataConnection.Free; |
| 1462 |
< |
Result := False; |
| 1460 |
> |
DataConnections[i].Close; |
| 1461 |
> |
DataConnections[i].Free; |
| 1462 |
> |
DataConnections[i] := nil; |
| 1463 |
> |
SetLength(DataConnections, Length(DataConnections) - 1); |
| 1464 |
> |
Result := nil; |
| 1465 |
|
end; |
| 1466 |
|
end; |
| 1467 |
|
|
| 1468 |
|
|
| 1469 |
|
|
| 1470 |
|
|
| 1471 |
< |
procedure CloseDataConnection; |
| 1471 |
> |
procedure CloseDataConnection(connection: TOniData); |
| 1472 |
> |
var |
| 1473 |
> |
i: Integer; |
| 1474 |
> |
found: Boolean; |
| 1475 |
|
begin |
| 1476 |
< |
if Assigned(OniDataConnection) then |
| 1476 |
> |
if Assigned(connection) then |
| 1477 |
|
begin |
| 1478 |
< |
OniDataConnection.Close; |
| 1479 |
< |
OniDataConnection := nil; |
| 1478 |
> |
found := False; |
| 1479 |
> |
for i := 0 to High(DataConnections) do |
| 1480 |
> |
begin |
| 1481 |
> |
if not found then |
| 1482 |
> |
begin |
| 1483 |
> |
if DataConnections[i] = connection then |
| 1484 |
> |
begin |
| 1485 |
> |
DataConnections[i].Close; |
| 1486 |
> |
DataConnections[i].Free; |
| 1487 |
> |
DataConnections[i] := nil; |
| 1488 |
> |
found := True; |
| 1489 |
> |
end; |
| 1490 |
> |
end |
| 1491 |
> |
else |
| 1492 |
> |
begin |
| 1493 |
> |
DataConnections[i - 1] := DataConnections[i]; |
| 1494 |
> |
end; |
| 1495 |
> |
end; |
| 1496 |
> |
if found then |
| 1497 |
> |
SetLength(DataConnections, Length(DataConnections) - 1); |
| 1498 |
|
end; |
| 1499 |
|
end; |
| 1500 |
|
|
| 1501 |
+ |
|
| 1502 |
+ |
|
| 1503 |
+ |
|
| 1504 |
+ |
constructor TOniDataEmpty.Create(OLDBFilename: String; var Result: Boolean); |
| 1505 |
+ |
var |
| 1506 |
+ |
i, j: Byte; |
| 1507 |
+ |
temps: String; |
| 1508 |
+ |
begin |
| 1509 |
+ |
ShowMessage('OLD'); |
| 1510 |
+ |
end; |
| 1511 |
+ |
|
| 1512 |
+ |
procedure TOniDataEmpty.Close; |
| 1513 |
+ |
begin |
| 1514 |
+ |
ShowMessage('OLD'); |
| 1515 |
+ |
end; |
| 1516 |
+ |
|
| 1517 |
|
end. |