Hello!
How is this for an interface for file operations?
Where do you think to implement this FileOperation interface?
I miss the "source" fileobject -a s I said, I dont want to implement the interface in the FileObject and thus thought about something like this:


DefaultFileOperations.get().copy(FileObject src, FileObject dest);

or - if you use your own (derived) implementation:

FileOperations fops = new MyFileOperations(); // this has to be done only once for the whole application
fops.copy(FileObject src, FileObject dest);


public interface FileOperation
{
void save(final OutputStream newContents, final FileObject dest, final boolean overwrite) throws FileSystemException;
void copy(final InputStream src, final FileObject dest, final boolean overwrite) throws FileSystemException;
void copy(final FileObject src, final FileObject dest, final boolean overwrite) throws FileSystemException;
void move(final FileObject src, final FileObject dest, final boolean overwrite) throws FileSystemException;
void backup(final FileObject file) throws FileSystemException;
}


If overwrite=false and the destination exists the methods should use "backup()" to create a backup of the destination file

Another thing we could discuss is the usage of save(InputStream, ...). I renamed it to copy(InputStream, ...). I think if you do have an InputStream you would like to copy its output to another file - in opposite to save(OutputStream ...) where you do have the content of the file in memory (a bufferedImage, ....) and would like to "save" it.
In this case the save(OutputStream ...) should write the content to a temporary file and later use move() to put it on its right place.


What do you think about this?

Ciao,
Mario


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to