简体   繁体   English

MacFUSE文件系统可以支持“虚拟”目录吗?

[英]Can a MacFUSE file system support “virtual” directories?

I'm toying around with MacFUSE, and it's pretty neat. 我正在玩MacFUSE,它非常简洁。 (I'm using the Objective-C API.) (我使用的是Objective-C API。)

I'm currently trying to build a filesystem that allows files to be classified by tags. 我目前正在尝试构建一个文件系统,该文件系统允许按标签对文件进行分类。 That is, I'd take a directory with a flat structure (and possibly lots of file), and moving a file into a directory would actually just attach a tag to it (without actually moving it). 也就是说,我将采用一个具有扁平结构(可能还有很多文件)的目录,然后将文件移动到目录中实际上只会在其上附加标签(而实际上不移动文件)。 When entering this directory, you would see all files that have that tag. 进入该目录时,您将看到所有具有该标签的文件。 You could also further move into subdirectories, which would yield only files that have all tags. 您还可以进一步进入子目录,这将仅产生具有所有标签的文件。

Problem is that there could be lots of tags, and I don't really like listing "fake" directories for the tags (especially since it also means I need to provide attributes for them). 问题是可能有很多标签,我真的不喜欢列出标签的“伪”目录(特别是因为这也意味着我需要为其提供属性)。 However, it seems impossible to open files or directories that aren't listed by contentsOfDirectoryAtPath:error . 但是,似乎不可能打开contentsOfDirectoryAtPath:error未列出的文件或目录。

Am I missing some convenient delegate method, or do I really have to list the tag directories as well? 我是否缺少一些方便的委托方法,还是真的必须列出标记目录?

Turns out that what MacFuse really wanted was attributes for the folders, and my attributesOfItemAtPath:(NSString *)path userData:(id)userData error:(NSError **)error didn't give them any. 事实证明MacFuse真正想要的是文件夹的属性,而我的attributesOfItemAtPath:(NSString *)path userData:(id)userData error:(NSError **)error没有给它们任何东西。

Giving the only mandatory attribute for folders ( NSFileType : NSDirectoryFileType ) seems to work "well enough". 为文件夹提供唯一的必需属性( NSFileTypeNSDirectoryFileType )似乎“足够好”地工作。 That is, the folders have a rather weak state of existence (anecdotal variations in the Finder causes the folder to "disappear" and the window to wind back to the file system root), but in the Terminal it works. 也就是说,文件夹的存在状态相当弱(Finder中的轶事变化会导致文件夹“消失”,并且窗口会回到文件系统根目录),但是在终端中它可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM