␉␊ |
␉return arr;␊ |
}␊ |
/// extract version info from boot files when possible␊ |
- (NSString*) cmdInfoForFile:(NSString*) file ␊ |
withFilter:(NSString*) filter␊ |
withPath:(NSString*) path␊ |
{␊ |
std::string p = [path UTF8String];␊ |
p += [file UTF8String];␊ |
␊ |
if (!fileExists(p)) return @"";␊ |
␊ |
NSString *cmd = [NSString stringWithFormat:@"strings \"%@%@\" | sed -nE '%@'",␊ |
path, file, filter];␊ |
// NSLog(@"cmd to run is %@", cmd);␊ |
return [NSString stringWithUTF8String: ShellProcess([cmd UTF8String]).get_line().c_str()];␊ |
}␊ |
␊ |
/// Get the boot information string, for chameleon only for now ...␊ |
-(NSString*) bootDescription␊ |
{␊ |
NSString* extractCmd = @"test -f \"%@boot\" && strings \"%@boot\" | sed -nE 's!^Darwin/x86 boot.+(Chameleon.+)!\\1!p'";␊ |
NSString* extractCmd2 = @"test -f \"%@mach_kernel\" && strings \"%@mach_kernel\" | sed -nE 's!^(Darwin Kernel Version.+)(\\: .*$)!\\1!p'";␊ |
NSString* localPath = [[self.vPath ␊ |
if (bootInfo != nil) return bootInfo;␊ |
␊ |
NSString* path = [[self.vPath ␊ |
stringByReplacingOccurrencesOfString: @"file://localhost"␊ |
withString:@""] ␊ |
stringByReplacingOccurrencesOfString:@"%20" withString:@" "];␊ |
NSString *cmdCham = [self cmdInfoForFile: @"boot" ␊ |
withFilter: @"s!^Darwin/x86 boot.+(Chameleon.+)!\\1!p"␊ |
withPath: path];␊ |
NSString *cmdDarwin = [self cmdInfoForFile: @"mach_kernel" ␊ |
withFilter: @"s!^(Darwin Kernel Version.+)(\\: .*$)!\\1!p"␊ |
withPath: path];␊ |
NSString *cmdWindows = (cmdDarwin==nil) ? @"" : ␊ |
[self cmdInfoForFile: @"boot.ini" ␊ |
withFilter: @"s!^multi.+WINDOWS=\\\"(.+)(\\\".+$)!\\1!p"␊ |
withPath: path];␊ |
␊ |
NSString * result = [[cmdCham stringByAppendingString: cmdDarwin] ␊ |
stringByAppendingString:cmdWindows];␊ |
result = [result stringByTrimmingCharactersInSet: ␊ |
[NSCharacterSet whitespaceAndNewlineCharacterSet] ];␊ |
␊ |
NSString* shellCmd = [NSString stringWithFormat:extractCmd, localPath, localPath ];␊ |
NSString* shellCmd2 = [NSString stringWithFormat:extractCmd2, localPath, localPath ];␊ |
std::string line = trim(ShellProcess([shellCmd UTF8String]).get_line(),"\n");␊ |
␊ |
if (line.length()>0)␊ |
{␊ |
return [NSString stringWithUTF8String:line.c_str()];␊ |
}␊ |
else if ( (line=trim(ShellProcess([shellCmd2 UTF8String]).get_line(),"\n")).length()>0)␊ |
{␊ |
return [NSString stringWithUTF8String:line.c_str()];␊ |
}␊ |
else␊ |
return @"Unknown booter version";␊ |
return (bootInfo = [result length] > 0 ? result : nil);␊ |
}␊ |
␊ |
␊ |
|
␉if (mediaPath != nil) [mediaPath release];␊ |
␉if (devProtocol != nil) [devProtocol release];␊ |
␉if (vAliasName != nil) [vAliasName release];␊ |
␉bsdName = vUUID = vKind = vName = mediaPath = devProtocol = vAliasName = nil;␊ |
␉if (bootInfo != nil) [bootInfo release];␊ |
␉bsdName = vUUID = vKind = vName = mediaPath = devProtocol = vAliasName = bootInfo = nil;␊ |
␉descDict = nil;␊ |
}␊ |
␊ |