Continue OS X installer work.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Helper.h
|
||||
// stepmania
|
||||
//
|
||||
// Created by Steve Checkoway on Mon Sep 08 2003.
|
||||
// Copyright (c) 2003 Steve Checkoway. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
@interface Helper : NSObject
|
||||
{
|
||||
NSString *mPath;
|
||||
}
|
||||
- (id) initWithPath:(NSString *)path;
|
||||
- (void)dealloc;
|
||||
- (void)startHelper:(id)caller;
|
||||
@end
|
||||
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// Helper.mm
|
||||
// stepmania
|
||||
//
|
||||
// Created by Steve Checkoway on Mon Sep 08 2003.
|
||||
// Copyright (c) 2003 Steve Checkoway. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Helper.h"
|
||||
#import "InstallerWindowController.h"
|
||||
#include "InstallerFile.h"
|
||||
#include "Processor.h"
|
||||
|
||||
static id c;
|
||||
|
||||
void HandleFile(const CString& file, const CString& archivePath, bool overwrite)
|
||||
{
|
||||
[c postMessage:[NSString stringWithCString:file]];
|
||||
}
|
||||
|
||||
const CString GetPath(const CString& ID)
|
||||
{
|
||||
[c postMessage:[NSString stringWithFormat:@"Get path for id: %s", ID.c_str()]];
|
||||
return "";
|
||||
}
|
||||
|
||||
void Error(const char *fmt, ...)
|
||||
{
|
||||
[c postMessage:@"error of some sort"];
|
||||
}
|
||||
|
||||
bool AskFunc(const CString& question)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@implementation Helper
|
||||
- (id)initWithPath:(NSString *)path
|
||||
{
|
||||
[super init];
|
||||
mPath = [path retain];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[mPath autorelease];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)startHelper:(id)caller
|
||||
{
|
||||
c = caller;
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
CString configPath = [mPath cString];
|
||||
CString archivePath = configPath + "/archive.tar.gz";
|
||||
|
||||
configPath += "/config";
|
||||
InstallerFile file(configPath);
|
||||
Processor p(archivePath, HandleFile, GetPath, AskFunc, YES);
|
||||
|
||||
p.SetErrorFunc(Error);
|
||||
|
||||
if(!file.ReadFile())
|
||||
{
|
||||
[c postMessage:@"Couldn't read the config file"];
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned nextLine = 0;
|
||||
while (nextLine < file.GetNumLines())
|
||||
p.ProcessLine(file.GetLine(nextLine), nextLine);
|
||||
|
||||
[c postMessage:@"Installation complete"];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* main.c
|
||||
* stepmania
|
||||
*
|
||||
* Created by Steve Checkoway on Mon Sep 08 2003.
|
||||
* Copyright (c) 2003 Steve Checkoway. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
return NSApplicationMain(argc, argv);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/* InstallerWindowController */
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "Helper.h"
|
||||
|
||||
@interface InstallerWindowController : NSWindowController
|
||||
{
|
||||
IBOutlet NSButton *button;
|
||||
IBOutlet NSTextView *textView;
|
||||
BOOL installing;
|
||||
Helper *helper;
|
||||
}
|
||||
- (void)awakeFromNib;
|
||||
- (void)dealloc;
|
||||
- (IBAction)pushedButton:(id)sender;
|
||||
- (void)postMessage:(NSString *)message;
|
||||
@end
|
||||
@@ -0,0 +1,29 @@
|
||||
#import "InstallerWindowController.h"
|
||||
|
||||
@implementation InstallerWindowController
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
helper = [[Helper alloc] initWithPath:@"files"];
|
||||
}
|
||||
|
||||
/* This whole method might be unneeded, I can't remember */
|
||||
- (void)dealloc
|
||||
{
|
||||
[helper autorelease];
|
||||
helper = nil;
|
||||
}
|
||||
|
||||
- (IBAction)pushedButton:(id)sender
|
||||
{
|
||||
[sender setEnabled:NO];
|
||||
[NSThread detachNewThreadSelector:@selector(startHelper:) toTarget:helper withObject:self];
|
||||
}
|
||||
|
||||
- (void)postMessage:(NSString *)message
|
||||
{
|
||||
NSString *temp = [NSString stringWithFormat:@"%@\n", message];
|
||||
|
||||
[textView insertText:temp];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user