我想以编程方式更改使用OSXFUSE(以前称为 MacFUSE)实现的堆叠文件系统的音量图标。图标需要反映已挂载文件系统的状态。
我一直在尝试的方法是将 /.VolumeIcon.icns 的请求映射到应用程序包中的适当图标。然后向文件系统发送实际路径(path)和挂载路径(mountPath)的更改通知。
[[NSWorkspace sharedWorkspace] noteFileSystemChanged: @"/Volumes"];
[[NSWorkspace sharedWorkspace] noteFileSystemChanged: [mountPath stringByDeletingLastPathComponent]];
[[NSWorkspace sharedWorkspace] noteFileSystemChanged: mountPath];
[[NSWorkspace sharedWorkspace] noteFileSystemChanged: [path stringByDeletingLastPathComponent]];
[[NSWorkspace sharedWorkspace] noteFileSystemChanged: path];
FNNotifyByPath([[[mountPath stringByDeletingLastPathComponent] dataUsingEncoding:NSUTF8StringEncoding] bytes], kFNDirectoryModifiedMessage, kNilOptions);
FNNotifyByPath([[[path stringByDeletingLastPathComponent] dataUsingEncoding:NSUTF8StringEncoding] bytes], kFNDirectoryModifiedMessage, kNilOptions);
FNNotifyByPath([[@"/Volumes" dataUsingEncoding:NSUTF8StringEncoding] bytes], kFNDirectoryModifiedMessage, kNilOptions);
单步调试调试器,我可以看到此代码被命中,但映射 /.VolumeIcon.icns 的代码很少被调用,并且从不响应这些通知。