Legacy java.io.File and new FileSystems

Michael Hall hallmike at att.net
Tue Aug 10 15:03:45 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Aug 10, 2010, at 3:54 PM, Alan Bateman wrote:
> To use the provider mechanism and other file system types requires  
> using the new API.

So as not to overly drag this out. If this means legacy File is left  
out of the use of the new FileSystems without a retrofit I think a  
opportunity is being missed to implement this transparently and pick  
up all the legacy code quite easily.

> you can think of File objects as being associated with the default  
> provider -- ie: for File f, then f.toPath().getFileSystem() will  
> return the default FileSystem

As you say you have a getFileSystem() method here that is pretty much  
unnecessary. It simply invokes the one and only platform FileSystem.  
Why not make this make a dispatcher that based on some mechanism  
dispatches the File instance to the correct 'logical' FileSystem.

I did implement something similar, it provided a zip based FileSystem  
by substituting for the involved java.io core classes. I had a System  
property that could be set, zip + <filename> = true
or something close to that.
Using this I could do javac compiles without any changes to javac  
where it would write it's output to a zip file transparently unaware  
that it's File's and FileOutputStreams were doing anything different.

If of interest to anyone, Transparent Random Zip
http://www195.pair.com/mik3hall/javasrc.html#trz
I am retooling this to work with jdk7 FileSystems. 1.6 pretty much  
busted it.

The point though is that if you don't already allow this it seems to  
me that allowing FileSystem dispatching would be an enhancement in  
allowing legacy code to work transparently without retrofitting.  
Making the new FileSystems more universal and useful.  There are a  
lot of existing File only programs out there.

Mike Hall        hallmike at att dot net
http://www195.pair.com/mik3hall
http://www195.pair.com/mik3hall/home.html
http://sourceforge.net/projects/macnative




-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)

iJwEAQECAAYFAkxhzMgACgkQUvk/ZSaThTLwuwP+IPX+LOfTQQZlcU2FbXgR8l2f
zWw4Ky8DlP7RBJEcWUccbkth4tnv85fEkv1COa8Kh2D9RFFQHHFSTrV2htpjzgCm
Zzc0zEdJHS5x6ZdVkzbfFN/ryKgyyBTQc9qtc8g2/FytK11nLCbLN/CA2BNwYVDw
OCypX/t7zaqSan04LjM=
=lKvm
-----END PGP SIGNATURE-----


More information about the nio-discuss mailing list