如何列出连接到Mac USB端口的设备?

4

如何在Objective C中列出连接到Mac的设备并获取它们的/dev/tty?

我非常希望为我过去一天左右构建的应用程序做到这一点。

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

2个回答

2

-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);
  }

我真的不明白这与任何相关性。 - Hasturkun

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接