root / ResourceBuilder.pas
History | View | Annotate | Download (1.9 kB)
| 1 | (*
|
|---|---|
| 2 | * CDDL HEADER START |
| 3 | * |
| 4 | * The contents of this file are subject to the terms of the |
| 5 | * Common Development and Distribution License, Version 1.0 only |
| 6 | * (the "License"). You may not use this file except in compliance |
| 7 | * with the License. |
| 8 | * |
| 9 | * You can obtain a copy of the license at |
| 10 | * http://www.opensource.org/licenses/cddl1.php. |
| 11 | * See the License for the specific language governing permissions |
| 12 | * and limitations under the License. |
| 13 | * |
| 14 | * When distributing Covered Code, include this CDDL HEADER in each |
| 15 | * file and include the License file at |
| 16 | * http://www.opensource.org/licenses/cddl1.php. If applicable, |
| 17 | * add the following below this CDDL HEADER, with the fields enclosed |
| 18 | * by brackets "[]" replaced with your own identifying * information: |
| 19 | * Portions Copyright [yyyy] [name of copyright owner] |
| 20 | * |
| 21 | * CDDL HEADER END |
| 22 | * |
| 23 | * |
| 24 | * Portions Copyright 2007 Andreas Schneider |
| 25 | *) |
| 26 | program ResourceBuilder;
|
| 27 | |
| 28 | {$mode objfpc}{$H+} |
| 29 | |
| 30 | uses
|
| 31 | SysUtils, Classes; |
| 32 | |
| 33 | var
|
| 34 | fileList: TStringList; |
| 35 | infile, outfile: TFileStream; |
| 36 | i, count: Integer; |
| 37 | size: Cardinal; |
| 38 | lookupTable: array of Cardinal; |
| 39 | |
| 40 | begin
|
| 41 | if ParamCount <> 2 then |
| 42 | begin
|
| 43 | writeln('Usage: ResourceBuilder <FileList> <ResourceFile>');
|
| 44 | halt; |
| 45 | end;
|
| 46 | |
| 47 | fileList := TStringList.Create; |
| 48 | fileList.LoadFromFile(ParamStr(1));
|
| 49 | outfile := TFileStream.Create(ParamStr(2), fmCreate);
|
| 50 | count := fileList.Count; |
| 51 | outfile.Write(count, SizeOf(Integer)); |
| 52 | SetLength(lookupTable, count); |
| 53 | outfile.Write(lookupTable[0], count * SizeOf(Cardinal));
|
| 54 | for i := 0 to count - 1 do |
| 55 | begin
|
| 56 | lookupTable[i] := outfile.Position; |
| 57 | writeln(i, ': ', fileList.Strings[i]);
|
| 58 | infile := TFileStream.Create(fileList.Strings[i], fmOpenRead); |
| 59 | infile.Position := 0;
|
| 60 | size := infile.Size; |
| 61 | outfile.Write(size, SizeOf(Cardinal)); |
| 62 | outfile.CopyFrom(infile, infile.Size); |
| 63 | infile.Free; |
| 64 | end;
|
| 65 | outfile.Position := SizeOf(Integer); |
| 66 | outfile.Write(lookupTable[0], count * SizeOf(Cardinal));
|
| 67 | outfile.Free; |
| 68 | fileList.Free; |
| 69 | end.
|