I have a multi-year task that performs a series of file operations on connected USB drives, and I want users to not unload the disk from the Finder (or anywhere else) when this happens. There is a Cancel button that allows you to complete the task at any time.
I suggested that keeping the file handle open on the mounted volume for the duration of the task will be a trick, but it did not work.
This is what I tried (error handling removed):
NSString *tempFilePath = @"/Volumes/myVolume/.myTempFile"; if ([[NSFileManager defaultManager] fileExistsAtPath:tempFilePath] == NO) { [[NSFileManager defaultManager] createFileAtPath:tempFilePath contents:nil attributes:nil] } _tempFile = [NSFileHandle fileHandleForWritingAtPath:tempFilePath];
Any ideas on what I can do to prevent a volume leak?
objective-c macos diskarbitration
mcsheffrey
source share