Index: apichanges.xml =================================================================== RCS file: /cvs/openide/fs/apichanges.xml,v retrieving revision 1.6 diff -u -r1.6 apichanges.xml --- apichanges.xml 3 Nov 2005 14:39:38 -0000 1.6 +++ apichanges.xml 3 May 2006 09:54:48 -0000 @@ -17,6 +17,26 @@ Filesystems API + + + Added additional method FileObject.getOutpuStream + that doesn't take FileLock as a parameter. + + + + + + +

+ Although newly added method FileObject.getOutpuStream + doesn't take FileLock as a parameter, the implementation + is responsible for taking a lock before OutputStream is + returned and thus FileAlreadyLockedException exception is thrown + when FileObject is already locked. +

+
+ +
Index: manifest.mf =================================================================== RCS file: /cvs/openide/fs/manifest.mf,v retrieving revision 1.6 diff -u -r1.6 manifest.mf --- manifest.mf 12 Dec 2005 15:40:12 -0000 1.6 +++ manifest.mf 3 May 2006 09:54:48 -0000 @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module: org.openide.filesystems -OpenIDE-Module-Specification-Version: 6.5 +OpenIDE-Module-Specification-Version: 6.6 OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties Index: src/org/openide/filesystems/FileObject.java =================================================================== RCS file: /cvs/openide/fs/src/org/openide/filesystems/FileObject.java,v retrieving revision 1.7 diff -u -r1.7 FileObject.java --- src/org/openide/filesystems/FileObject.java 21 Apr 2006 19:30:46 -0000 1.7 +++ src/org/openide/filesystems/FileObject.java 3 May 2006 09:54:48 -0000 @@ -17,6 +17,7 @@ import java.io.File; import java.io.FileNotFoundException; +import java.io.FilterOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -475,6 +476,30 @@ */ public abstract OutputStream getOutputStream(FileLock lock) throws IOException; + + /** Get output stream. + * @return output stream to overwrite the contents of this file + * @throws IOException if an error occures (the file is invalid, etc.) + * @throws FileAlreadyLockedException if the file is already locked + */ + public final OutputStream getOutputStream() throws FileAlreadyLockedException, IOException { + final FileLock lock = lock(); + final OutputStream os = getOutputStream(lock); + return new FilterOutputStream(os) { + public void close() throws IOException { + try { + super.close(); + lock.releaseLock(); + } catch(IOException iex) { + if (lock.isValid()) { + lock.releaseLock(); + } + throw iex; + } + } + }; + } + /** Lock this file. * @return lock that can be used to perform various modifications on the file