简体   繁体   中英

Can a MacFUSE file system support “virtual” directories?

I'm toying around with MacFUSE, and it's pretty neat. (I'm using the 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 .

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.

Giving the only mandatory attribute for folders ( NSFileType : NSDirectoryFileType ) seems to work "well enough". 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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