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

Archive Download this file

Revision: 453