I'm trying to use the wonderful VFS. It works quite well but I've a problem with writing in zip file. Searching for informations, I wonder if VFS is still a live project and if sometimes, it will leave the sandbox to become a complete Jakarta-Common project ?
I'd like to see some more utility methods for manipulating file objects. For example, much of my code needs:
void saveAs() throws IOException; void moveTo() throws IOException; void copyTo() throws IOException;
I use these as high-level operations which use do-or-die semantics (succeed or throw an exception) and call more basic file object operations to do the work. Here is the implementation of saveAs() with a lot of things unexplained (but I use readable names, so I hope that helps -- a WhimFile is just a java.io.File with these extra operations; I'm using it to demonstrate my ideas to my coworkers):
private static void saveMaybeBackup(final WhimFile original, final InputStream newContents, final boolean keepBackup) throws IOException { final WhimFile scratch = original.createTempWhimFile("save", null);
try { copyAndClose(newContents, scratch.getOutputStream());
if (keepBackup && original.exists()) original.moveToWithOverwrite(original.createBackupFile());
// TODO: if scratch.moveTo throws, restore original from backup? scratch.moveToWithOverwrite(original);
} finally { scratch.delete(); } }
Cheers, --binkley
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]