Chameleon Applications

Chameleon Applications Svn Source Tree

Root/trunk/ChameleonPrefPane/test_util/test_util.mm

1//
2// ChameleonPrefPane
3//
4// test utility for the chameleon preference pane
5//
6// Created by Rekursor on 11-11-12.
7//
8
9#import <Foundation/Foundation.h>
10#import "PartitionInfoElement.h"
11#import "PartitionInfoManager.h"
12#import "SmbiosExtractor.h"
13#import "ShellProcess.h"
14#include "string_util.h"
15#include <string>
16#include <iostream>
17
18void testDiskInfoWith(NSString * bsd)
19{
20PartitionInfoElement* di = [[PartitionInfoElement alloc] initWithBSDName: bsd];
21
22if ([di isValid] && [di.vUUID length] >0)
23{
24#if 1
25NSLog(@"bsdName %@", [di bsdName] );
26NSLog(@"deviceProtocol %@", [ di devProtocol] );
27NSLog(@"volumeName %@", [di vName]);
28NSLog(@"volumePath %@", [di vPath]);
29NSLog(@"volumeKind %@", [di vKind]);
30NSLog(@"deviceInternal %i", (int) [ di devInternal] );
31NSLog(@"volumeUUID %@", [di vUUID]);
32NSLog(@"mediaPath %@", [di mediaPath]);
33NSLog(@"mediaRemovable %i", (int) [di mediaRemovable]);
34
35NSLog(@"\n");
36
37#else
38int i = 0;
39for (NSString* o in di.descDict)
40{
41 id value = [di.descDict objectForKey: o];
42 if (value == nil) value = @"<nil>";
43 NSLog(@"Key: %@, Value: %@", o, value );
44 i++;
45}
46#endif
47}
48
49[di release];
50}
51
52int main (int argc, const char * argv[])
53{
54 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
55
56SmbiosExtractor* smbe = [[SmbiosExtractor alloc] init];
57[smbe save:@"/tmp/chmIOreg.plist"];
58NSLog(@"SMBIOS = \n%@", smbe);
59
60#if 1
61NSArray* arr = [PartitionInfoElement createBSDPartitionList];
62NSLog(@"List of existing bsd disk partitions:\n %@", arr);
63
64for (PartitionInfoElement* part in [PartsInfoMgr parts])
65NSLog(@"PartionBootable = %i\n%@", (int) [part isBootable], part);
66/*
67[PartsInfoMgr hideParts: @"\"Macintosh HD\" hd(0,3)"];
68[PartsInfoMgr hideParts: @"disk0s2 hd(0,2) "];
69[PartsInfoMgr hideParts: @"BOOTCAMP \"Macintosh HD\""];
70[PartsInfoMgr hideParts: @"3E9C6A92-3737-4C0F-9003-20B2482D61FB"];
71*/
72[PartsInfoMgr renameParts: @"hd(0,2) \"Test\""];
73[PartsInfoMgr renameParts: @"hd(0,3) Fantastic"];
74[PartsInfoMgr renameParts: @"hd(0,4) \"A BC\"; hd(0,2) DEF"];
75
76#else
77testDiskInfoWith(@"disk0s2");
78testDiskInfoWith(@"disk0s3");
79#endif
80 fprintf(stderr, "String Test\n");
81 std::string options = "-v darkwake ab= a=0 =abc -f";
82 fprintf(stderr, "options = %s\n", options.c_str() );
83 std::list<std::string> l = tokenize(options, " ");
84 std::list<std::string>::const_iterator it = l.begin();
85 for (; it != l.end(); it++)
86 {
87 std::string s = *it;
88 std::cerr << "token: " << s
89 << ", left: " << string_left(s, "=")
90 << ", right: " << string_right(s, "=")
91 << ", trim: " << trim(s)
92 << std::endl;
93 }
94
95 [pool drain];
96 return 0;
97}
98

Archive Download this file

Revision: 458