2011-03-27 86 views
4

如何列出连接到mac的设备并在Objective C中获取其/ dev/tty文件?如何列出连接到Mac的USB端口的设备?

我真的很喜欢这样做的应用程序,我一直在过去一天左右的建设。

我需要列出连接到mac的设备,并找到一个适合我的标准的应用程序。如何找到这些设备,并将它们的/ dev/tty列为NSString列表?

回答

-1

头文件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); 
    } 
+0

我实在看不出这是如何相关的。 – Hasturkun 2011-06-09 16:16:35