- Timestamp:
- Dec 23, 2006, 11:16:42 PM (18 years ago)
- Location:
- oup/current
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Code/OniDataClass.pas
r46 r51 2 2 interface 3 3 uses Data, DataStructures, Classes, SysUtils, StrUtils, 4 Dialogs, ABSDecUtil, ABSMain, DB ;4 Dialogs, ABSDecUtil, ABSMain, DB, Windows; 5 5 6 6 type … … 103 103 FDatabase: TABSDatabase; 104 104 FQuery: TABSQuery; 105 Fdat_files: TFiles; 106 Fdat_extensionsmap: TExtensionsMap; 105 107 protected 106 108 public … … 108 110 procedure Close; override; 109 111 112 procedure UpdateListCache; 110 113 // function GetDatLinks(srcid:LongWord):TDatLinks; 111 114 function GetFileInfo(fileid: LongWord): TFileInfo; override; … … 849 852 FQuery.Close; 850 853 854 UpdateListCache; 855 851 856 Result := True; 852 857 FBackend := ODB_ADB; … … 865 870 866 871 867 868 function TOniDataADB.GetFileInfo(fileid: LongWord): TFileInfo; 869 begin 870 if fileid < Self.GetFilesCount then 871 begin 872 FQuery.SQL.Text := 'SELECT * FROM datfiles WHERE id=' + IntToStr( 873 fileid) + ' ORDER BY id ASC;'; 874 FQuery.Open; 875 if FQuery.RecordCount = 1 then 876 begin 877 FQuery.First; 878 Result.ID := FQuery.FieldByName('id').AsInteger; 879 Result.Name := FQuery.FieldByName('name').AsString; 880 Result.Extension := FQuery.FieldByName('extension').AsString; 881 Result.FileName := FormatNumber(Result.ID, 5, '0') + '-' + Result.Name + '.' + 882 Result.Extension; 883 Result.Size := FQuery.FieldByName('size').AsInteger; 884 Result.FileType := HexToLong(FQuery.FieldByName('contenttype').AsString); 885 Result.DatAddr := 0; 886 Result.opened := False; 887 end; 888 FQuery.Close; 889 end 890 else 891 begin 892 Result.ID := -1; 893 end; 894 end; 895 896 897 898 899 function TOniDataADB.GetFilesList(ext: String; pattern: String; 900 NoEmptyFiles: Boolean; sort: TSortType): TStringArray; 872 procedure TOniDataADB.UpdateListCache; 901 873 var 902 874 i: LongWord; 903 where: String; 904 where_ext: String; 905 order: String; 906 begin 907 where := ''; 908 if Length(ext) > 0 then 909 begin 910 if Length(where) > 0 then 911 where := where + ' AND '; 912 if Pos(',', ext) > 0 then 913 begin 914 i := 1; 915 where_ext := ''; 916 while i < Length(ext) do 917 begin 918 if Length(where_ext) > 0 then 919 where_ext := where_ext + ' OR '; 920 where_ext := where_ext + '(extension="' + MidStr(ext, i, 4) + '")'; 921 i := i + 5; 922 end; 923 where := where + '(' + where_ext + ')'; 924 end 925 else 926 begin 927 where := where + '(extension="' + ext + '")'; 928 end; 929 end; 930 if Length(pattern) > 0 then 931 begin 932 if Length(where) > 0 then 933 where := where + ' AND '; 934 where := where + '(name LIKE "%' + pattern + '%")'; 935 end; 936 if NoEmptyFiles then 937 begin 938 if Length(where) > 0 then 939 where := where + ' AND '; 940 where := where + '(contenttype<>2)'; 941 end; 942 if Length(where) > 0 then 943 where := ' WHERE ' + where; 944 case sort of 945 stIDAsc: order := ' ORDER BY id ASC'; 946 stIDDesc: order := ' ORDER BY id DESC'; 947 stNameAsc: order := ' ORDER BY name ASC, id ASC'; 948 stNameDesc: order := ' ORDER BY name DESC, id ASC'; 949 stExtAsc: order := ' ORDER BY extension ASC, id ASC'; 950 stExtDesc: order := ' ORDER BY extension DESC, id ASC'; 951 end; 952 FQuery.SQL.Text := 'SELECT id,name,extension FROM datfiles' + where + order + ';'; 875 temps: String; 876 begin 877 FQuery.SQL.Text := 'SELECT id,name,extension,[size],contenttype FROM datfiles ORDER BY id ASC;'; 953 878 FQuery.Open; 954 879 if FQuery.RecordCount > 0 then 955 880 begin 956 881 FQuery.First; 957 SetLength( Result, FQuery.RecordCount);882 SetLength(Fdat_files, FQuery.RecordCount); 958 883 i := 0; 959 884 repeat 960 Result[i] := FormatNumber(FQuery.FieldByName('id').AsInteger, 5, '0') + '-' + 961 FQuery.FieldByName('name').AsString + '.' + FQuery.FieldByName('extension').AsString; 885 Fdat_files[i].ID := FQuery.FieldByName('id').AsInteger; 886 Fdat_files[i].Name := FQuery.FieldByName('name').AsString; 887 Fdat_files[i].Extension := FQuery.FieldByName('extension').AsString; 888 Fdat_files[i].FileName := FormatNumber(Fdat_files[i].ID, 5, '0') + '-' + 889 Fdat_files[i].Name + '.' + Fdat_files[0].Extension; 890 Fdat_files[i].FileNameHex := IntToHex(Fdat_files[i].ID, 4) + '-' + 891 Fdat_files[i].Name + '.' + Fdat_files[0].Extension; 892 Fdat_files[i].Size := FQuery.FieldByName('size').AsInteger; 893 Fdat_files[i].FileType := HexToLong(FQuery.FieldByName('contenttype').AsString); 894 Fdat_files[i].DatAddr := 0; 895 Fdat_files[i].opened := False; 962 896 Inc(i); 963 897 FQuery.Next; … … 965 899 end; 966 900 FQuery.Close; 967 end; 968 969 970 971 972 function TOniDataADB.GetFilesCount: LongWord; 973 begin 974 FQuery.SQL.Text := 'SELECT Count(*) AS cnumber FROM datfiles;'; 975 FQuery.Open; 976 if FQuery.RecordCount > 0 then 977 begin 978 FQuery.First; 979 Result := FQuery.FieldByName('cnumber').AsInteger; 980 end 981 else 982 Result := 0; 983 FQuery.Close; 984 end; 985 986 987 988 989 function TOniDataADB.GetExtensionsList: TStringArray; 990 var 991 i: LongWord; 992 begin 993 SetLength(Result, 0); 901 902 SetLength(Fdat_extensionsmap, 0); 994 903 FQuery.SQL.Text := 995 904 'SELECT extension,count(extension) AS x FROM datfiles GROUP BY extension ORDER BY extension ASC;'; … … 997 906 if FQuery.RecordCount > 0 then 998 907 begin 999 SetLength( Result, FQuery.RecordCount);908 SetLength(Fdat_extensionsmap, FQuery.RecordCount); 1000 909 i := 0; 1001 910 repeat 1002 Result[i] := FQuery.FieldByName('extension').AsString + ' (' + 1003 IntToStr(FQuery.FieldByName('x').AsInteger) + ')'; 911 temps := FQuery.FieldByName('extension').AsString[1]; 912 Fdat_extensionsmap[i].Extension[3] := temps[1]; 913 Fdat_extensionsmap[i].Extension[2] := temps[2]; 914 Fdat_extensionsmap[i].Extension[1] := temps[3]; 915 Fdat_extensionsmap[i].Extension[0] := temps[4]; 916 Fdat_extensionsmap[i].ExtCount := FQuery.FieldByName('x').AsInteger; 1004 917 Inc(i); 1005 918 FQuery.Next; … … 1007 920 end; 1008 921 FQuery.Close; 922 end; 923 924 925 function TOniDataADB.GetFileInfo(fileid: LongWord): TFileInfo; 926 var 927 i: Integer; 928 begin 929 if fileid < Self.GetFilesCount then 930 begin 931 for i := 0 to High(Fdat_files) do 932 if Fdat_files[i].ID = fileid then 933 Break; 934 if i < Length(Fdat_files) then 935 Result := Fdat_files[i] 936 else 937 Result.ID := -1; 938 end 939 else 940 begin 941 Result.ID := -1; 942 end; 943 end; 944 945 946 947 948 function TOniDataADB.GetFilesList(ext: String; pattern: String; 949 NoEmptyFiles: Boolean; sort: TSortType): TStringArray; 950 var 951 i: LongWord; 952 list: TStringList; 953 id, name, extension: String; 954 fields: TStrings; 955 956 procedure getfields; 957 begin 958 fields.CommaText := StringReplace(AnsiQuotedStr(list.Strings[i], '"'), ';', '","', [rfReplaceAll]); 959 if sort in [stIDAsc, stIDDesc] then 960 begin 961 id := fields.Strings[0]; 962 name := fields.Strings[1]; 963 extension := fields.Strings[2]; 964 end; 965 if sort in [stNameAsc, stNameDesc] then 966 begin 967 id := fields.Strings[1]; 968 name := fields.Strings[0]; 969 extension := fields.Strings[2]; 970 end; 971 if sort in [stExtAsc, stExtDesc] then 972 begin 973 id := fields.Strings[1]; 974 name := fields.Strings[2]; 975 extension := fields.Strings[0]; 976 end; 977 end; 978 979 begin 980 list := TStringList.Create; 981 list.Sorted := True; 982 for i := 0 to High(Fdat_files) do 983 begin 984 if ((Length(ext) = 0) or (Pos(Fdat_files[i].Extension, ext) > 0)) and 985 ((Length(pattern) = 0) or 986 (Pos(UpperCase(pattern), UpperCase(Fdat_files[i].Name)) > 0)) then 987 begin 988 if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then 989 begin 990 if AppSettings.FilenumbersAsHex then 991 id := IntToHex(Fdat_files[i].ID, 4) 992 else 993 id := FormatNumber(Fdat_files[i].ID, 5, '0'); 994 name := Fdat_files[i].Name; 995 extension := Fdat_files[i].Extension; 996 997 case sort of 998 stIDAsc, stIDDesc: list.Add(id + ';' + name + ';' + extension); 999 stNameAsc, stNameDesc: list.Add(name + ';' + id + ';' + extension); 1000 stExtAsc, stExtDesc: list.Add(extension + ';' + id + ';' + name); 1001 end; 1002 end; 1003 end; 1004 end; 1005 SetLength(Result, list.Count); 1006 fields := TStringList.Create; 1007 if sort in [stIDAsc, stNameAsc, stExtAsc] then 1008 for i := 0 to list.Count - 1 do 1009 begin 1010 getfields; 1011 Result[i] := id + '-' + name + '.' + extension; 1012 end 1013 else 1014 for i := list.Count - 1 downto 0 do 1015 begin 1016 getfields; 1017 Result[list.Count - i - 1] := id + '-' + name + '.' + extension; 1018 end; 1019 list.Free; 1020 fields.Free; 1021 end; 1022 1023 1024 1025 1026 function TOniDataADB.GetFilesCount: LongWord; 1027 begin 1028 Result := Length(Fdat_files); 1029 end; 1030 1031 1032 1033 1034 function TOniDataADB.GetExtensionsList: TStringArray; 1035 var 1036 i: LongWord; 1037 begin 1038 SetLength(Result, Length(Fdat_extensionsmap)); 1039 for i := 0 to High(Result) do 1040 begin 1041 with Fdat_extensionsmap[i] do 1042 begin 1043 Result[i] := Extension[3] + Extension[2] + Extension[1] + Extension[0] + 1044 ' (' + IntToStr(ExtCount) + ')'; 1045 end; 1046 end; 1009 1047 end; 1010 1048 … … 1139 1177 mem.Seek(0, soFromBeginning); 1140 1178 FQuery.SQL.Text := 'UPDATE datfiles SET data=MimeToBin("' + 1141 MimeCoder.StrTo(mem.Memory, mem.Size) + '") WHERE id=' + IntToStr(fileid) + ';'; 1179 MimeCoder.StrTo(mem.Memory, mem.Size) + '"), size=' + IntToStr(mem.Size) + 1180 ' WHERE id=' + IntToStr(fileid) + ';'; 1142 1181 FQuery.ExecSQL; 1143 1182 mem.Free; 1144 1183 mimecoder.Free; 1145 1184 end; 1185 UpdateListCache; 1146 1186 end; 1147 1187 -
oup/current/Main.dfm
r46 r51 52 52 Caption = 'MainMenu' 53 53 CloseButton = False 54 DragHandleStyle = dhDouble 54 55 FullSize = True 55 56 Images = MenuImages … … 124 125 ShortCut = 16453 125 126 OnClick = menu_extractorClick 127 end 128 object menu_meta: TTBItem 129 Caption = '&Meta Editor' 130 Enabled = False 131 ShortCut = 16461 132 OnClick = menu_metaClick 126 133 end 127 134 object menu_filecompare: TTBItem … … 198 205 Top = 23 199 206 Caption = 'Toolbar' 207 DragHandleStyle = dhDouble 200 208 Images = MenuImages 201 209 TabOrder = 1 210 OnDockChanged = ToolbarDockChanged 202 211 object tbOpen: TTBItem 203 212 Caption = 'Open file' … … 207 216 end 208 217 object tb_separator1: TTBSeparatorItem 218 end 219 object tb_dat2db: TTBItem 220 Caption = '.dat -> DB' 221 DisplayMode = nbdmImageAndText 222 ImageIndex = 1 223 OnClick = menu_createdbClick 224 end 225 object tb_db2dat: TTBItem 226 Caption = 'DB -> .dat' 227 DisplayMode = nbdmImageAndText 228 ImageIndex = 2 229 OnClick = menu_createlvlClick 230 end 231 object TBSeparatorItem1: TTBSeparatorItem 209 232 end 210 233 object tb_preview: TTBItem … … 242 265 ImageIndex = 7 243 266 OnClick = menu_extractorClick 267 end 268 object tb_meta: TTBItem 269 Caption = 'Meta Editor' 270 DisplayMode = nbdmImageAndText 271 Enabled = False 272 OnClick = menu_metaClick 244 273 end 245 274 object tb_compare: TTBItem … … 264 293 DockPos = 0 265 294 DockRow = 2 295 DragHandleStyle = dhDouble 266 296 TabOrder = 2 267 297 object TBControlItem1: TTBControlItem -
oup/current/Main.pas
r46 r51 67 67 tb_datedit: TTBItem; 68 68 menu_windows_tilevert: TTBItem; 69 tb_meta: TTBItem; 70 menu_meta: TTBItem; 71 TBSeparatorItem1: TTBSeparatorItem; 72 tb_db2dat: TTBItem; 73 tb_dat2db: TTBItem; 69 74 function TryCloseAll: Boolean; 70 75 procedure menu_AboutClick(Sender: TObject); … … 99 104 Shift: TShiftState; X, Y: Integer); 100 105 procedure menu_windows_tilevertClick(Sender: TObject); 106 procedure menu_metaClick(Sender: TObject); 107 procedure ToolbarDockChanged(Sender: TObject); 101 108 private 102 109 public … … 280 287 281 288 289 procedure TForm_Main.ToolbarDockChanged(Sender: TObject); 290 var 291 toolbar: TTBToolbar; 292 position: TTBDockPosition; 293 mode: TTBItemDisplayMode; 294 i: Integer; 295 isEnabled: Boolean; 296 begin 297 toolbar := TTBToolbar(Sender); 298 if toolbar.Floating then 299 mode := nbdmImageAndText 300 else begin 301 position := toolbar.CurrentDock.Position; 302 if position in [dpLeft, dpRight] then 303 mode := nbdmDefault 304 else 305 mode := nbdmImageAndText; 306 end; 307 for i := 0 to toolbar.Items.Count - 1 do 308 toolbar.Items.Items[i].DisplayMode := mode; 309 end; 310 282 311 function TForm_Main.TryCloseAll: Boolean; 283 312 begin … … 426 455 427 456 457 procedure TForm_Main.menu_metaClick(Sender: TObject); 458 begin 459 ShowMessage('TBD'); 460 end; 461 462 428 463 procedure TForm_Main.menu_filecompareClick(Sender: TObject); 429 464 begin -
oup/current/Tools/Template.dfm
r46 r51 29 29 AutoSnap = False 30 30 Beveled = True 31 MinSize = 15 031 MinSize = 155 32 32 ExplicitHeight = 473 33 33 end … … 62 62 200 63 63 129) 64 object Label2: TLabel 65 Left = 100 66 Top = 105 67 Width = 17 68 Height = 18 69 AutoSize = False 70 Caption = '.' 71 Font.Charset = DEFAULT_CHARSET 72 Font.Color = clWindowText 73 Font.Height = -13 74 Font.Name = 'Tahoma' 75 Font.Style = [fsBold] 76 ParentFont = False 77 end 78 object Label1: TLabel 79 Left = 47 80 Top = 105 81 Width = 17 82 Height = 18 83 AutoSize = False 84 Caption = '-' 85 Font.Charset = DEFAULT_CHARSET 86 Font.Color = clWindowText 87 Font.Height = -13 88 Font.Name = 'Tahoma' 89 Font.Style = [fsBold] 90 ParentFont = False 91 end 64 92 object label_ext: TLabel 65 93 Left = 2 … … 72 100 end 73 101 object btn_sort_id_asc: TSpeedButton 74 Left = 1675 Top = 101 76 Width = 2 3102 Left = 3 103 Top = 101 104 Width = 20 77 105 Height = 22 78 106 Hint = 'Sort files by id, ascending' … … 93 121 end 94 122 object btn_sort_id_desc: TSpeedButton 95 Left = 4096 Top = 101 97 Width = 2 3123 Left = 23 124 Top = 101 125 Width = 20 98 126 Height = 22 99 127 Hint = 'Sort files by id, descending' … … 113 141 end 114 142 object btn_sort_name_asc: TSpeedButton 115 Left = 64116 Top = 101 117 Width = 2 3143 Left = 58 144 Top = 101 145 Width = 20 118 146 Height = 22 119 147 Hint = 'Sort files by name, ascending' … … 133 161 end 134 162 object btn_sort_name_desc: TSpeedButton 135 Left = 88136 Top = 101 137 Width = 2 3163 Left = 78 164 Top = 101 165 Width = 20 138 166 Height = 22 139 167 Hint = 'Sort files by name, descending' … … 153 181 end 154 182 object btn_sort_ext_asc: TSpeedButton 155 Left = 1 12156 Top = 101 157 Width = 2 3183 Left = 108 184 Top = 101 185 Width = 20 158 186 Height = 22 159 187 Hint = 'Sort files by extension, ascending' 160 188 GroupIndex = 1 189 Glyph.Data = { 190 F6000000424DF600000000000000760000002800000010000000100000000100 191 0400000000008000000000000000000000001000000000000000C0C0C0000000 192 9900990000000000000000000000000000000000000000000000000000000000 193 0000000000000000000000000000000000000000000000000000000000000000 194 0000011111100000300001100010000030000011000000033300000110000003 195 3300000011000033333001000110000030000111111000003000000000000000 196 3000022202220000300000200020000030000022222000003000000202000000 197 3000000222000000300000002000000030000000200000003000} 161 198 ParentShowHint = False 162 199 ShowHint = True … … 164 201 end 165 202 object btn_sort_ext_desc: TSpeedButton 166 Left = 1 36167 Top = 101 168 Width = 2 3203 Left = 128 204 Top = 101 205 Width = 20 169 206 Height = 22 170 207 Hint = 'Sort files by extension, descending' 171 208 GroupIndex = 1 209 Glyph.Data = { 210 F6000000424DF600000000000000760000002800000010000000100000000100 211 0400000000008000000000000000000000001000000000000000C0C0C0000000 212 9900990000000000000000000000000000000000000000000000000000000000 213 0000000000000000000000000000000000000000000000000000000000000000 214 0000022202220000300000200020000030000022222000033300000202000003 215 3300000222000033333000002000000030000000200000003000000000000000 216 3000011111100000300001100010000030000011000000003000000110000000 217 3000000011000000300001000110000030000111111000003000} 172 218 ParentShowHint = False 173 219 ShowHint = True … … 187 233 Font.Name = 'Tahoma' 188 234 Font.Style = [] 189 ItemHeight = 0235 ItemHeight = 13 190 236 ParentFont = False 191 237 Sorted = True -
oup/current/Tools/Template.pas
r46 r51 34 34 btn_sort_ext_asc: TSpeedButton; 35 35 btn_sort_ext_desc: TSpeedButton; 36 Label1: TLabel; 37 Label2: TLabel; 36 38 procedure RecreateList; 37 39 procedure LoadFileNames; … … 82 84 i: LongWord; 83 85 exts: TStringArray; 84 begin 86 f, c1,c2: Int64; 87 time1,time2,time3: Double; 88 begin 89 QueryPerformanceFrequency(f); 90 QueryPerformanceCounter(c1); 85 91 combo_extension.Items.Clear; 86 92 combo_extension.Items.Add('_All files_ (' + … … 96 102 end else 97 103 combo_extension.Items.Add(exts[i]); 104 QueryPerformanceCounter(c2); 105 time1 := (c2 - c1) / f; 98 106 combo_extension.ItemIndex := 0; 99 107 combo_extensionClick(Self); 108 QueryPerformanceCounter(c1); 109 time2 := (c1 - c2) / f; 110 ShowMessage(FloatToStr(time1) +#13+#10+ FloatToStr(time2)); 100 111 end; 101 112 -
oup/current/text/todo.txt
r46 r51 49 49 -Cursor Sanduhr bei Wartezeiten (db-access etc) 50 50 51 -RawMap: was ist laut link+size used bereich, was nicht52 -StructViewer Raw: DynamicInfos aus .dat53 54 51 -Exporter: Checkboxes für was man im einzelnen will (zb Checkbox "in eine Datei ja/nein") 55 52 -Extrahier-Ordner-Option (mit Platzhalter für .dat-Name) … … 57 54 58 55 -Hex: Paste 59 60 -Persist.dat editor61 56 62 57
Note:
See TracChangeset
for help on using the changeset viewer.