
//======================================================================
//
//	Portions written by FreemanSoft Inc.
//
//	FreemanSoft disclaims any warranty of any kind, expressed or implied,
//	as to this source code's fitness for any particular use.
//
//	For more information, use the following electronic mail addresses:
//	 
//		info@FreemanSoft.com	general questions
//		support@FreemanSoft.com	technical questions
//
//======================================================================


/* Written by
 *	Joe Freeman	jfreeman@next.com	
 *	RdistControl
 *
 *	This code has no warranty.  
 *	It is provided so that the consumer may maintain and modify it
 *	at their own risk.  Use this code at your own risk.
 */

#import "CDROMIndexControl.h"
#import "DragView.h"
#import "Subprocess.h"
#import "pathutil.h"
#import "common.h"
#import "cdromControl.h"		// strings entries

#import "JumpBackControl.h"


/*================================================================
 *	Private methods 
 *================================================================*/
 
@implementation CDROMIndexControl

	

- (const char *)buttonImageName
{
    return "Index_ROM.tiff";
}

- (const char *)buttonAltImageName
{
    return "Index_ROM_abort.tiff";
}

- (const char *)stringsTable
{
    return "cdromControl";
}

- free
{
    [[NXApp delegate] dropDragJumpBackController:self];
    return [super free];
}

#define pass_1_run_string "%s %s %s"
	
- runPassOne:sender
{
    char	buf[MAXPATHLEN+1];
    char	fwPath[MAXPATHLEN+1];	/* writable check executable */

    canContinue = YES;
    [[NXBundle mainBundle] getPath: fwPath
			forResource:make_dir_script ofType:""];
    if (fwPath && *fwPath){
			[self setState: PASS_1_RUNNING];
			[self logIt: start_pass_1_string];
			sprintf(buf, pass_1_run_string, 
					fwPath, sPathList, dPathList);
			subprocessObj = [Subprocess new:buf
				withDelegate:self
				andPtySupport:NO
				andStdErr:YES];	
    } else {
			[self logIt: missing_make_dir_script];
			[self abortProcess:self];
    }
    return self;
}

	
- runPassTwo:sender
{	
    char buf[1024];
    
    canContinue = YES;
    [self setState:PASS_2_RUNNING];
    [self logIt:start_pass_2_string];
    sprintf(buf, pass_2_run_string, 	dPathList, basename(sPathList));
    subprocessObj = [Subprocess new:buf
				withDelegate:self
				andPtySupport:NO
				andStdErr:YES];
    [subprocessObj terminateInput];
    return self;
}


@end
