0
这里的时候是一个问题,当我使用NSTask来卸载当前的USB驱动器,它会给我以下错误:目标C:错误使用NSTask卸载USB驱动器
2013-06-03 09:39:41.096 NAME[1028:303] in moving file view controller
dyld: DYLD_ environment variables being ignored because main executable
(/usr/sbin/diskutil) has __RESTRICT/__restrict section
Unmount of disk1 failed: at least one volume could not be unmounted
我对分区我mac so disk1我认为是mac os。 下面是我用卸载我的硬盘功能:
//When I call this function by passing all of these arguments:
NSArray* arrayForCloseUSBDrive = [[NSArray arrayWithObjects:@"diskutil", @"unmountDisk",@"/Volumes/AAA/",nil]autorelease];
[Utility handleDrive:@"/usr/bin/env" arrayArguments:arrayForCloseUSBDrive];
//It will start run this function in Utility class:
+(void)handleDrive:(NSString*)launchPath arrayArguments:(NSArray*)array
{
NSTask *task = [NSTask new];
[task setLaunchPath:launchPath];
[task setArguments:array];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];
[task launch];
[task waitUntilExit];
}
为什么不在'NSWorkspace'中使用本地'-unmount *'方法之一? –
我试过了,但它也不起作用。其实,当我试图在终端上卸载磁盘时,它仍然给我错误说:“卸载磁盘1失败:至少有一个卷无法卸载” –
所以你需要找出为什么你不能卸载它。当前用户是否安装了卷?是否还有打开该卷的任何文件?在终端中,'fuser -uc/Volumes/MyMountPoint'会向您显示进程和拥有它们的用户,这些用户拥有在该文件系统上打开的文件。只要打开任何文件,文件系统就无法卸载。 –