stephan 2002/08/19 00:57:21 Modified: src/java/org/apache/cocoon/components/source/impl FileSource.java src/java/org/apache/cocoon/components/source WriteableSource.java Log: New methods COPY, MOVE, DELETE for WriteableSource. Revision Changes Path 1.6 +43 -1 xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/FileSource.java Index: FileSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/FileSource.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- FileSource.java 13 Jun 2002 09:48:49 -0000 1.5 +++ FileSource.java 19 Aug 2002 07:57:21 -0000 1.6 @@ -253,4 +253,46 @@ throw new IllegalArgumentException("The stream is not associated to this source"); } + /** + * Move the source to source.getSystemId(), including all properties + * deletes this source. + * + * @param source Destination of the source. + */ + public void move(WriteableSource source) throws SourceException { + this.copy(source); + this.delete(); + } + + /** + * Copy the source to source.getSystemId(), including all properties. + * + * @param source Destination of the source. + */ + public void copy(WriteableSource source) throws SourceException { + try { + OutputStream out = source.getOutputStream(); + InputStream in = getInputStream(); + + byte[] buffer = new byte[8192]; + int length = -1; + + while ((length = in.read(buffer)) > -1) { + out.write(buffer, 0, length); + } + in.close(); + out.flush(); + out.close(); + } catch (IOException ioe) { + throw new SourceException("Could not copy source : "+ioe.getMessage()); + } + } + + /** + * Delete the source. + */ + public void delete() throws SourceException { + if (!this.file.delete()) + throw new SourceException("Could not delete source."); + } } 1.4 +22 -2 xml-cocoon2/src/java/org/apache/cocoon/components/source/WriteableSource.java Index: WriteableSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/WriteableSource.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- WriteableSource.java 4 Jul 2002 11:46:05 -0000 1.3 +++ WriteableSource.java 19 Aug 2002 07:57:21 -0000 1.4 @@ -110,4 +110,24 @@ * After cancel, the stream should no more be used. */ void cancel(OutputStream stream) throws SourceException; -} \ No newline at end of file + + /** + * Move the source to source.getSystemId(), including all properties + * deletes this source. + * + * @param source Destination of the source. + */ + void move(WriteableSource source) throws SourceException; + + /** + * Copy the source to source.getSystemId(), including all properties. + * + * @param source Destination of the source. + */ + void copy(WriteableSource source) throws SourceException; + + /** + * Delete the source. + */ + void delete() throws SourceException; +}
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]