Sebastian Celis wrote:
>I have found some information on accessing the resource fork through the
>following Java code:
>File file = new File("file.txt/..namedfork/rsrc");
>
>However, dumping the bytes of this file to a "._file.txt" does not appear
>to give me the file that I want. In fact, the bytes of this file are quite
>different than the one created if I drag "file.txt" to another file system
>(by doing something like 'cp file.txt /Volumes/foo/').
The contents of a "dot-underscore" file are in AppleDouble format. It is
not a pure resource fork. You can find myriad references by googling for
applesingle or appledouble.
Only getting access to the resource fork, however it's accomplished, is not
sufficient. There are crucial metadata elements not present in the
resource fork, and not accessible to Java by any means outside JNI.
Without that metadata, you cannot reversibly encode the original file. The
decoded file will not be the same as what was encoded, and the difference
may be very significant.
>I would much prefer to be able to do this without writing any JNI, as I
>would like to avoid forcing all clients to install native code. I'd much
>rather they be able to just use the applet on the server.
>
>Is this at all possible? Is there any way to transform the data from
>"file.txt/..namedfork/rsrc" to match the format in "._file.txt"?
I see very few possible solutions.
1) Use my open source MacBinary Toolkit to access the resource fork and
metadata. Optionally, encode with MacBinary, if all uploadable files fit
within its limitations (< 4 GB data fork, < 63 bytes for name).
The down side to MacBinary Toolkit is it uses JNI, so can't work from an
applet without being pre-installed.
<http://www.amug.org/~glguerin/sw/#macbinary>
2) Find an exec()'able command that can encode resource fork and metadata
on behalf of your applet, and then give your applet exec() permission.
I don't know of any such command off the top of my head, but someone else
might. Note that commands like ditto and cp will copy resource forks and
metadata, but they don't encode it. You may be able to trick them into
encoding it if you mount a temp file-system (disk-image) with FAT format,
from which you can directly read the "dot-underscore" file.
3) Use a deployment technology other than applets. Java Web Start can
deploy JNI libs. It's pre-installed on Macs, so it's not a separate
download.
Downside is Safari users need the "Open 'safe' files" checkbox checked,
which is unwise as a blanket security setting. Nor do I know of a way to
alter what Safari consider 'safe', which seems pretty silly these days.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden