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'會向您顯示進程和擁有它們的用戶,這些用戶擁有在該文件系統上打開的文件。只要打開任何文件,文件系統就無法卸載。 –