installer/Attach.dpr
author Christian Hammacher <bmasterc@gmail.com>
Fri Oct 07 15:42:18 2005 +0000 (2005-10-07)
changeset 126 b072ae770357
child 169 314eb459448e
permissions -rw-r--r--
Added MM:S installer to the CVS [MM:S installer is a modifed copy of the AMX Mod X installer]
bmasterc@126
     1
program Attach;
bmasterc@126
     2
bmasterc@126
     3
{$APPTYPE CONSOLE}
bmasterc@126
     4
bmasterc@126
     5
uses
bmasterc@126
     6
  SysUtils, Classes, UnitPackSystem;
bmasterc@126
     7
bmasterc@126
     8
var eStream: TMemoryStream;
bmasterc@126
     9
    eFiles: TStringList;
bmasterc@126
    10
begin
bmasterc@126
    11
  WriteLn('// File attacher for the MM:S installer');
bmasterc@126
    12
  WriteLn('// by Basic-Master');
bmasterc@126
    13
  WriteLn('');
bmasterc@126
    14
  WriteLn('// Looking up files...');
bmasterc@126
    15
  { Check files }
bmasterc@126
    16
  if FileExists(ExtractFilePath(ParamStr(0)) + 'files\server.dll') then
bmasterc@126
    17
    WriteLn('// Found files\server.dll')
bmasterc@126
    18
  else begin
bmasterc@126
    19
    WriteLn('// Error: Couldn''t find files\server.dll!');
bmasterc@126
    20
    ReadLn;
bmasterc@126
    21
    exit;
bmasterc@126
    22
  end;
bmasterc@126
    23
  if FileExists(ExtractFilePath(ParamStr(0)) + 'files\server_i486.so') then
bmasterc@126
    24
    WriteLn('// Found files\server_i486.so')
bmasterc@126
    25
  else begin
bmasterc@126
    26
    WriteLn('// Error: Couldn''t find files\server_i486.so!');
bmasterc@126
    27
    ReadLn;
bmasterc@126
    28
    exit;
bmasterc@126
    29
  end;
bmasterc@126
    30
  if FileExists(ExtractFilePath(ParamStr(0)) + 'MMS_Installer.exe') then
bmasterc@126
    31
    WriteLn('// Found MMS_Installer.exe')
bmasterc@126
    32
  else begin
bmasterc@126
    33
    WriteLn('// Error: Couldn''t find MMS_Installer.exe!');
bmasterc@126
    34
    ReadLn;
bmasterc@126
    35
    exit;
bmasterc@126
    36
  end;
bmasterc@126
    37
  { Compress files }
bmasterc@126
    38
  WriteLn('// Compressing files...');
bmasterc@126
    39
  eFiles := TStringList.Create;
bmasterc@126
    40
  eFiles.Add(ExtractFilePath(ParamStr(0)) + 'files\server.dll');
bmasterc@126
    41
  eFiles.Add(ExtractFilePath(ParamStr(0)) + 'files\server_i486.so');
bmasterc@126
    42
  eStream := TMemoryStream.Create;
bmasterc@126
    43
  CompressFiles(eFiles, ExtractFilePath(ParamStr(0)) + 'temp.zip');
bmasterc@126
    44
  eStream.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'temp.zip');
bmasterc@126
    45
  WriteLn('// Attaching output to MMS_Installer.exe...');
bmasterc@126
    46
  AttachToFile(ExtractFilePath(ParamStr(0)) + 'MMS_Installer.exe', eStream);
bmasterc@126
    47
  DeleteFile(ExtractFilePath(ParamStr(0)) + 'temp.zip');
bmasterc@126
    48
  eStream.Free;
bmasterc@126
    49
  WriteLn('// Done.');
bmasterc@126
    50
  ReadLn;
bmasterc@126
    51
end.