my filthy hack...
Ryan C. Gordon
icculus at clutteredmind.org
Wed Sep 18 10:02:31 EDT 2002
...time is short, and I'm not going to use the latest loki_setup at this
point. i hit a bug somewhere, and my fried brain tried to fix it and made
it worse, and I gave up.
Here's the dirty hack I eventually decided on for the compressed files for
now. It's a plugin...sorta.
Naptime.
--ryan.
-------------- next part --------------
/* Sample plugin for setup */
/* $Id: sample.c,v 1.3 2002/04/03 08:10:25 megastep Exp $ */
#include <string.h>
#include "plugins.h"
#include "file.h"
#include "install_log.h"
/* Initialize the plugin */
static int InitPlugin(void)
{
/* TODO: Initialize the plugin here, if necesary.
Returns a boolean value upon success.
*/
return 1;
}
/* Free the plugin */
static int FreePlugin(void)
{
/* TODO: Clean up the plugin here, if necesary.
Returns a boolean value upon success.
*/
return 1;
}
/* Get the size of the file */
static size_t Size(install_info *info, const char *path)
{
/* TODO: Return the size of the uncompressed file */
return 0;
}
/* Extract the file */
static size_t Copy(install_info *info, const char *path, const char *dest, const char *current_option, xmlNodePtr node,
int (*update)(install_info *info, const char *path, size_t progress, size_t size, const char *current))
{
char buf[1024];
stream *input, *output;
size_t retval = 0;
size_t total = 0;
char *fname;
char dstpath[BUFSIZ];
strcpy(dstpath, path);
fname = strrchr(dstpath, '/');
if (fname != NULL)
{
*fname = '\0';
fname++;
}
else
{
fname = dstpath;
}
update(info, path, 0, 1000000, current_option);
snprintf(buf, sizeof (buf),
"cp %s $SETUP_INSTALLPATH/%s || exit 1 ;"
" cd $SETUP_INSTALLPATH/System ;"
" export LD_LIBRARY_PATH=\".;$LD_LIBRARY_PATH\" ;"
" ./ucc-bin decompress ../%s -nohomedir ;"
" rm -f ./UT2003.ini ;"
" rm -f ./User.ini ;"
" rm -f ./ucc.ini ;"
" rm -f ./server.ini ;"
" rm -f ./StdOut.log ;"
" rm -f ./ucc.log ;"
" rm -f ../%s ;"
" exit 0",
path, fname, fname, fname);
if (run_script(info, buf, 0) != 0)
log_fatal("failed to uncompress file.");
snprintf(buf, sizeof (buf), "%s/%s", info->install_path, fname);
buf[strlen(buf) - 4] = 0;
total = file_size(info, buf);
input = file_open(info, buf, "rb");
if ( input == NULL ) {
unlink(buf);
return(-1);
}
snprintf(buf, sizeof(buf), "%s/%s/%s", dest, dstpath, fname);
buf[strlen(buf) - 4] = 0;
output = file_open(info, buf, "wb");
if ( output == NULL ) {
snprintf(buf, sizeof (buf), "%s/%s", info->install_path, fname);
buf[strlen(buf) - 4] = 0;
unlink(buf);
file_close(info, input);
return(-1);
}
while ( ! file_eof(info, input) ) {
char readbuf[BUFSIZ];
int br = file_read(info, readbuf, (sizeof readbuf), input);
if (br > 0)
{
if (file_write(info, readbuf, br, output) != br)
log_fatal("write error uncompressing file.");
retval += br;
}
update(info, path, retval, total, current_option);
}
file_close(info, input);
file_close(info, output);
snprintf(buf, sizeof (buf), "%s/%s", info->install_path, fname);
buf[strlen(buf) - 4] = 0;
unlink(buf);
return(retval);
}
#ifdef DYNAMIC_PLUGINS
static
#endif
SetupPlugin uz2_plugin = {
"UZ2 Plugin",
"1.0",
"Ryan C. Gordon <ryan at epicgames.com>",
1, {".uz2"},
InitPlugin, FreePlugin,
Size, Copy
};
#ifdef DYNAMIC_PLUGINS
SetupPlugin *GetSetupPlugin(void)
{
return &uz2_plugin;
}
#endif
More information about the Lokisetup
mailing list