Revision: 1683 http://svn.sourceforge.net/vexi/?rev=1683&view=rev Author: mkpg2 Date: 2007-02-17 08:03:34 -0800 (Sat, 17 Feb 2007)
Log Message: ----------- Make fountains (potentially) writeable Modified Paths: -------------- core/trunk/org.ibex.js/src/org/ibex/js/Fountain.java Modified: core/trunk/org.ibex.js/src/org/ibex/js/Fountain.java =================================================================== --- core/trunk/org.ibex.js/src/org/ibex/js/Fountain.java 2007-02-17 15:54:37 UTC (rev 1682) +++ core/trunk/org.ibex.js/src/org/ibex/js/Fountain.java 2007-02-17 16:03:34 UTC (rev 1683) @@ -7,9 +7,11 @@ import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -35,6 +37,7 @@ // Public Interface ////////////////////////////////////////////////////////////////////////////// public static InputStream getInputStream(JS js) throws IOException { return ((Fountain)js.unclone()).getInputStream();} + public static OutputStream getOutputStream(JS js) throws IOException { return ((Fountain)js.unclone()).getOutputStream();} public static class NotCacheableException extends Exception { } // streams are "sealed" by default to prevent accidental object leakage @@ -56,6 +59,10 @@ // call stack) here as InputStream is not a JS object! public abstract InputStream getInputStream() throws IOException; + public OutputStream getOutputStream() throws IOException{ + throw new IOException(toString() + " is read only"); + } + // Perform any caching (Fountain.Multi calls this on its // constituent streams so that it can cache everything up // front). @@ -125,13 +132,20 @@ /** a file */ public static class File extends Fountain { private String path; - public File(String path) { this.path = path; } + private boolean writeable; + public File(String path) { this(path,true); } + public File(String path, boolean writeable) { this.path = path; this.writeable = writeable;} public String coerceToString() { return "File:" + path; } public String getCacheKey() throws NotCacheableException { throw new NotCacheableException(); /* already on disk */ } public InputStream getInputStream() throws IOException { try{return new FileInputStream(path); }catch(FileNotFoundException e){return null;} } + public OutputStream getOutputStream() throws IOException { + if(!writeable) throw new IOException("File readonly: " + coerceToString()); + try{return new FileOutputStream(path); + }catch(FileNotFoundException e){return null;} + } public JS _get(JS key) throws JSExn { return new File(path + java.io.File.separatorChar + JSU.toString(key)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn