comparison core/src/luan/modules/Utils.java @ 187:1cb298d918b2

ban "//" in file and java paths git-svn-id: https://luan-java.googlecode.com/svn/trunk@188 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 26 Jun 2014 03:27:25 +0000
parents 3dcb0f9bee82
children 99eef1d0e706
comparison
equal deleted inserted replaced
186:cf939124461a 187:1cb298d918b2
59 throw new RuntimeException(e); 59 throw new RuntimeException(e);
60 } 60 }
61 } 61 }
62 62
63 public static boolean isFile(String path) { 63 public static boolean isFile(String path) {
64 return exists(new File(path)); 64 return !path.contains("//") && exists(new File(path));
65 } 65 }
66 66
67 public static String toUrl(String path) { 67 public static String toUrl(String path) {
68 if( path.indexOf(':') == -1 ) 68 if( path.indexOf(':') == -1 )
69 return null; 69 return null;
70 if( path.startsWith("java:") ) { 70 if( path.startsWith("java:") ) {
71 path = path.substring(5); 71 path = path.substring(5);
72 if( path.contains("//") )
73 return null;
72 URL url = ClassLoader.getSystemResource(path); 74 URL url = ClassLoader.getSystemResource(path);
73 return url==null ? null : url.toString(); 75 return url==null ? null : url.toString();
74 } 76 }
75 try { 77 try {
76 new URL(path); 78 new URL(path);