Revision: 4696 http://sourceforge.net/p/vexi/code/4696 Author: mkpg2 Date: 2014-05-10 23:08:29 +0000 (Sat, 10 May 2014) Log Message: ----------- Check case of resources when loading from the filesystem. - when developing on windows, possible to use incorrect case in a template, previously mistake only later detected when running from a .vexi file (causing deployment issues).
Modified Paths: -------------- branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Resources.java branches/vexi3/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Fountain.java branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/stream/TestStream.java trunk/org.vexi-library.crypto/src/main/java/org/vexi/DotVexi.java Added Paths: ----------- branches/vexi3/org.vexi-library.js/src/poke/java/poke/PokeFS.java Modified: branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Resources.java =================================================================== --- branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Resources.java 2014-05-10 14:21:51 UTC (rev 4695) +++ branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Resources.java 2014-05-10 23:08:29 UTC (rev 4696) @@ -76,7 +76,7 @@ JS arg = JSU.getArg(args,0); try { File f = createTempFile(arg); - return new Fountain.File(f,true); + return new Fountain.File(f,true,false); } catch (IOException e) { throw new JSExn(e); } @@ -162,7 +162,7 @@ // run local vexi files File checkfile = new File(arg); if (checkfile.exists()) { - r = new Fountain.File(arg); + r = new Fountain.File(arg, false, DotVexi.isCaseInsensitive()); if (!checkfile.isDirectory()) { r = Fountain.newZip((Fountain.File)r); } Modified: branches/vexi3/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp =================================================================== --- branches/vexi3/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp 2014-05-10 14:21:51 UTC (rev 4695) +++ branches/vexi3/org.vexi-core.main/src/main/jpp/org/vexi/core/Vexi.jpp 2014-05-10 23:08:29 UTC (rev 4696) @@ -704,7 +704,7 @@ if (f==null) { return null; } - return new Fountain.File(f,write); + return new Fountain.File(f,write,false); } public JS callMethod(JS this_, JS method, JS[] args) throws JSExn { Modified: branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Fountain.java =================================================================== --- branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Fountain.java 2014-05-10 14:21:51 UTC (rev 4695) +++ branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Fountain.java 2014-05-10 23:08:29 UTC (rev 4696) @@ -308,14 +308,28 @@ /** a file */ public static class File extends Fountain { final public String path; - private boolean writeable; - public File(String path) throws JSExn { this(path,true); } - public File(String path, boolean writeable) throws JSExn { - this(new java.io.File(path), writeable); + final private boolean writeable; + final private boolean checkCase; + public File(String path) throws JSExn { this(path,true,false); } + public File(String path, boolean writeable, boolean checkCase) throws JSExn { + this(new java.io.File(path), writeable, checkCase); } - public File(java.io.File file, boolean writeable) throws JSExn { - try{this.path = file.getCanonicalPath();}catch(IOException e){throw new JSExn(e.getMessage());} + public File(java.io.File file, boolean writeable, boolean checkCase) throws JSExn { + java.io.File fileC; + try{ + fileC = file.getCanonicalFile(); + }catch(IOException e){throw new JSExn(e.getMessage());} + if(checkCase){ + // REMARK when reading vexi source files we want to require case sensitivity, even when the filesystem + // is not. Otherwise it is possible to test things in windows only for them to later not work + // when running from a zip. + if(!file.getName().equals(fileC.getName())){ + throw new JSExn("Expected '"+file.getName()+"', actual file '"+fileC.getName()+"'"); + } + } + this.path = fileC.getPath(); this.writeable = writeable; + this.checkCase = checkCase; } public String canonical() { return "file://"+path; } public JS getInfo() throws IOException { @@ -340,10 +354,9 @@ if(expect) throw new IOException("File readonly: " + coerceToString()); return null; } - java.io.File f = new java.io.File(path); return new FileOutputStream(path); } - public JS _get(JS key) throws JSExn { return new File(path + java.io.File.separatorChar + JSU.toString(key)); } + public JS _get(JS key) throws JSExn { return new File(path + java.io.File.separatorChar + JSU.toString(key), writeable, checkCase); } public void remove() throws JSExn { if(writeable){ new java.io.File(path).delete(); Added: branches/vexi3/org.vexi-library.js/src/poke/java/poke/PokeFS.java =================================================================== --- branches/vexi3/org.vexi-library.js/src/poke/java/poke/PokeFS.java (rev 0) +++ branches/vexi3/org.vexi-library.js/src/poke/java/poke/PokeFS.java 2014-05-10 23:08:29 UTC (rev 4696) @@ -0,0 +1,13 @@ +package poke; + +import java.io.File; +import java.io.IOException; + +public class PokeFS { + static public void main(String[] args) throws IOException { + File f = new File("readme.txt"); + System.err.println(f.exists()); + System.err.println(f.getName()); + System.err.println(f.getCanonicalFile().getName()); + } +} Property changes on: branches/vexi3/org.vexi-library.js/src/poke/java/poke/PokeFS.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/stream/TestStream.java =================================================================== --- branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/stream/TestStream.java 2014-05-10 14:21:51 UTC (rev 4695) +++ branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/stream/TestStream.java 2014-05-10 23:08:29 UTC (rev 4696) @@ -32,7 +32,7 @@ File tmpDir = Utilities.createTmpDir(); final File save_ = new File(tmpDir,"save"+count+++".txt"); TestCase.assertTrue(!save_.exists() || save_.delete()); - Fountain.File save = new Fountain.File(save_.getPath(),true); + Fountain.File save = new Fountain.File(save_.getPath(),true,false); return new JSTestCase(directory, fileName, new Prop[]{new Prop("tempstream",save)}); } catch (JSExn e) { throw new Error(e); Modified: trunk/org.vexi-library.crypto/src/main/java/org/vexi/DotVexi.java =================================================================== --- trunk/org.vexi-library.crypto/src/main/java/org/vexi/DotVexi.java 2014-05-10 14:21:51 UTC (rev 4695) +++ trunk/org.vexi-library.crypto/src/main/java/org/vexi/DotVexi.java 2014-05-10 23:08:29 UTC (rev 4696) @@ -1,10 +1,14 @@ // SHOULD probably find a better package/project for this package org.vexi; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; -import org.vexi.security.*; +import org.ibex.util.DefaultLog; +import org.vexi.security.VerifySigned; // SHOULD probably find a better home (different project)! abstract public class DotVexi { @@ -205,6 +209,25 @@ } } - - + static Boolean IS_WINDOWS; + + static private boolean detectWindows(){ + String osName = System.getProperty("os.name"); + DefaultLog.logger.info(DotVexi.class, "OS: "+osName); + if (osName.startsWith("Windows")) { + DefaultLog.logger.info(DotVexi.class, "Detected Windows"); + return true; + } else { + return false; + } + } + + static public boolean isWindows(){ + if(IS_WINDOWS==null){ + IS_WINDOWS = Boolean.valueOf(detectWindows()); + } + return IS_WINDOWS.booleanValue(); + } + + static public boolean isCaseInsensitive(){ return isWindows(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Is your legacy SCM system holding you back? Join Perforce May 7 to find out: • 3 signs your SCM is hindering your productivity • Requirements for releasing software faster • Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn