4
如何列出連接到mac的設備並在Objective C中獲取其/ dev/tty文件?如何列出連接到Mac的USB端口的設備?
我真的很喜歡這樣做的應用程序,我一直在過去一天左右的建設。
我需要列出連接到mac的設備,並找到一個適合我的標準的應用程序。如何找到這些設備,並將它們的/ dev/tty列爲NSString列表?
如何列出連接到mac的設備並在Objective C中獲取其/ dev/tty文件?如何列出連接到Mac的USB端口的設備?
我真的很喜歡這樣做的應用程序,我一直在過去一天左右的建設。
我需要列出連接到mac的設備,並找到一個適合我的標準的應用程序。如何找到這些設備,並將它們的/ dev/tty列爲NSString列表?
Finding and Accessing Devices會爲您提供更多信息。
頭文件Mounter.h
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
@interface Mounter : NSObject {
struct statfs *buf;
int i, count;
@private
}
-(void) getMountList;
@end
實施Mounter.m文件:
#import "Mounter.h"
@implementation Mounter
-(void) getMountList {
NSFileManager *fm = [NSFileManager defaultManager];
count = getmntinfo(&buf, 0);
for (i=0; i<count; i++)
{
NSString *path = [NSString stringWithUTF8String:buf[i].f_mntonname];
NSLog(@"Drivers: %@", path);
}
我實在看不出這是如何相關的。 – Hasturkun 2011-06-09 16:16:35