Mac specific file meta information using nio.2 attributes
Michael Hall
mik3hall at gmail.com
Sat Jun 2 20:05:15 PDT 2012
I have put together something to provide some Mac platform api meta data using nio.2 and a little jni. Possibly it's to the point where there might be some feedback.
If not of interest skip the rest.
The download if you want to skip to that…
http://www195.pair.com/mik3hall/trz.zip
Mostly this is a follow up to this old java-dev list post
http://lists.apple.com/archives/java-dev/2011/Jul/msg00031.html
Re: JDK 1.7 & listing MacOS X file metadata? [was Re: OpenJDK 1.7]
It attempts to provide a default 'file' scheme FileSystemProvider that is pass through for everything except the attributes which are overridden.
Currently it supports 9 different Finder, mac_finder, attributes. Both getAttributes and setAttributes should be supported.
For example for the locked flag that the above post was concerned with you could use something like…
Files.setAttribute(p,"mac_finder:locked","true");
or
Files.getAttribute(p,"mac_finder:locked");
It supports 13 different Launch Services, mac_ls, attributes, currently read only, getters there but setters shouldn't work. Some probably could have setters, some not.
I decided not to do the application specific file type meta data that is mentioned in the list post. Although applications are meta rich files the Apple api's don't really support getting at it.
I thought about hacking something using lsregister -dump maybe but decided against forcing an api.
I still think if you have a meta rich file type that you work with a lot you could use this approach to provide custom attributes just for that file type.
I am considering providing additional Cocoa NSFileManager meta information though. However, avoiding any more overlap than what is in the two views mentioned. How many ways do you need to access type/creator?
It doesn't support BasicFileAttribute FileAttribute classes, so the bulk readAtttribute methods passing such classes aren't available. They possibly could be made so.
Not a lot of testing to make sure all the pass through works. What JUnit testing there is, is in us.halll.trz.osx.test.MacAttributesTest, this might provide a little example usage to see what it's more or less doing.
It would be a little disappointing to hear this is a terrible idea and I've been wasting my time. Other than that feedback would probably be welcome.
More information about the macosx-port-dev
mailing list