Index: oup/current/FileClasses/TXMP.pas
===================================================================
--- oup/current/FileClasses/TXMP.pas	(revision 207)
+++ oup/current/FileClasses/TXMP.pas	(revision 209)
@@ -4,5 +4,5 @@
 
 uses
-  TypeDefs, _FileTypes, _DataTypes;
+  _FileTypes;
 
 type
@@ -17,19 +17,7 @@
 
 uses
-  ConnectionManager, Math, Classes;
+  ConnectionManager, Math, Classes, TypeDefs, _DataTypes;
 
-{ TFile_SNDD }
-
-procedure TFile_TXMP.InitDatLinks;
-begin
-  SetLength(FDatLinks, 2);
-  FDatLinks[0].SrcOffset := $94;
-  FDatLinks[0].DestID := -1;
-  FDatLinks[0].PosDestExts := '*';
-  FDatLinks[1].SrcOffset := $98;
-  FDatLinks[1].DestID := -1;
-  FDatLinks[1].PosDestExts := 'TXMP';
-end;
-
+{ TFile_TXMP }
 
 procedure TFile_TXMP.InitDataFields;
@@ -119,4 +107,16 @@
 
 
+procedure TFile_TXMP.InitDatLinks;
+begin
+  SetLength(FDatLinks, 2);
+  FDatLinks[0].SrcOffset := $94;
+  FDatLinks[0].DestID := GetDatLinkValue(FFile, $94);
+  FDatLinks[0].PosDestExts := '*';
+  FDatLinks[1].SrcOffset := $98;
+  FDatLinks[1].DestID := GetDatLinkValue(FFile, $98);
+  FDatLinks[1].PosDestExts := 'TXMP';
+end;
+
+
 procedure TFile_TXMP.InitRawList;
 var
Index: oup/current/FileClasses/_FileManager.pas
===================================================================
--- oup/current/FileClasses/_FileManager.pas	(revision 209)
+++ oup/current/FileClasses/_FileManager.pas	(revision 209)
@@ -0,0 +1,81 @@
+unit _FileManager;
+interface
+
+uses _FileTypes, TXMP;
+
+type
+  TFileType = class of TFile;
+  TFileDesc = record
+    ext: String;
+    ftype: TFileType;
+  end;
+
+const
+  FileDescs: array[0..0] of TFileDesc = (
+    (ext: 'TXMP'; ftype: TFile_TXMP)
+  );
+
+type
+  TFileManager = class
+    protected
+      FFiles: array of TFile;
+      FConnectionID: Integer;
+      function GetFileCount: Integer;
+      function GetFileById(Id: Integer): TFile;
+    public
+      constructor Create(ConnectionID: Integer);
+
+      property FileCount: Integer read GetFileCount;
+      property FileById[Id: Integer]: TFile read GetFileById;
+  end;
+
+implementation
+
+uses
+  Classes, ConnectionManager, Access_OniArchive, TypeDefs, Dialogs, SysUtils, StrUtils;
+
+{ TFileManager }
+
+constructor TFileManager.Create(ConnectionID: Integer);
+var
+  files: TStrings;
+  i: Integer;
+  typei: Integer;
+  fid: Integer;
+begin
+  FConnectionID := ConnectionID;
+  if ConManager.Connection[ConnectionID] is TAccess_OniArchive then
+    TAccess_OniArchive(ConManager.Connection[ConnectionID]).UnloadWhenUnused := False;
+  files := TStringList.Create;
+  files := ConManager.Connection[ConnectionID].GetFilesList('', '', False, ST_IDAsc);
+  if files.Count > 0 then
+  begin
+    for i := 0 to files.Count - 1 do
+    begin
+      for typei := 0 to High(FileDescs) do
+      begin
+        if Pos('.' + FileDescs[typei].ext, files.Strings[i]) = Length(files.Strings[i]) - 4 then
+        begin
+          SetLength(FFiles, Length(FFiles) + 1);
+          fid := StrToInt(MidStr(files.Strings[i], 1, 5));
+          FFiles[High(FFiles)] := TFileType(FileDescs[typei].ftype).Create(FConnectionID, fid);
+        end;
+      end;
+    end;
+  end;
+  files.Free;
+  if ConManager.Connection[ConnectionID] is TAccess_OniArchive then
+    TAccess_OniArchive(ConManager.Connection[ConnectionID]).UnloadWhenUnused := True;
+end;
+
+function TFileManager.GetFileById(Id: Integer): TFile;
+begin
+  Result := FFiles[Id];
+end;
+
+function TFileManager.GetFileCount: Integer;
+begin
+  Result := Length(FFiles);
+end;
+
+end.
Index: oup/current/FileClasses/_FileTypes.pas
===================================================================
--- oup/current/FileClasses/_FileTypes.pas	(revision 207)
+++ oup/current/FileClasses/_FileTypes.pas	(revision 209)
@@ -12,4 +12,5 @@
       FConnectionID: Integer;
       FFileID: Integer;
+      FFileName: String;
       FFile: TMemoryStream;
 
@@ -34,4 +35,5 @@
       property FileStream: TMemoryStream read FFile;
       property FileID: Integer read FFileID;
+      property FileName: String read FFileName;
       property ConnectionID: Integer read FConnectionID;
 
@@ -50,4 +52,8 @@
 
 
+function GetDatLinkValue(stream: TStream; offset: Integer): Integer;
+
+
+
 implementation
 
@@ -63,5 +69,5 @@
   FConnectionID := ConnectionID;
   FFileID := FileID;
-  FFile := nil;
+  FFileName := ConManager.Connection[ConnectionID].GetFileInfo(FileID).Name;
 
   FFile := TMemoryStream.Create;
@@ -71,12 +77,4 @@
   InitDataFields();
   InitRawList();
-
-  if FDataFields.FieldCount > 0 then
-  begin
-    for i := 0 to FDataFields.FieldCount - 1 do
-    begin
-      ShowMessage(FDataFields.FieldByIndex[i].ValueAsString);
-    end;
-  end;
 
   FFile.Free;
@@ -171,3 +169,15 @@
 end;
 
+
+
+function GetDatLinkValue(stream: TStream; offset: Integer): Integer;
+begin
+  stream.Seek(Offset, soFromBeginning);
+  stream.Read(Result, 4);
+  if Result > 0 then
+    Result := Result div 256
+  else
+    Result := -1;
+end;
+
 end.
