platform/android/Rhodes/src/com/rhomobile/rhodes/Utils.java in rhodes-2.2.6 vs platform/android/Rhodes/src/com/rhomobile/rhodes/Utils.java in rhodes-2.3.0.beta.1

- old
+ new

@@ -73,19 +73,45 @@ if (stream2 != null) stream2.close(); } } public static void deleteRecursively(File target) throws IOException { + if (!target.exists()) + return; + if (target.isDirectory()) { String[] children = target.list(); for(int i = 0; i != children.length; ++i) deleteRecursively(new File(target, children[i])); } + + //platformLog("delete", target.getPath()); + if (!target.delete()) throw new IOException("Can not delete " + target.getAbsolutePath()); } + + public static void deleteChildrenIgnoreFirstLevel(File target, String strIgnore) throws IOException { + if (!target.exists()) + return; + if (target.isDirectory()) { + String[] children = target.list(); + for(int i = 0; i != children.length; ++i) + { + File f = new File(target, children[i]); + if ( f.isDirectory()) + deleteRecursively(f); + else if ( !f.getName().startsWith(strIgnore)) + { + if (!target.delete()) + throw new IOException("Can not delete " + target.getAbsolutePath()); + } + } + } + } + public static void copyRecursively(FileSource fs, String source, File target, boolean remove) throws IOException { if (remove && target.exists()) deleteRecursively(target); @@ -167,15 +193,24 @@ RhodesService r = RhodesService.getInstance(); File hash = new File(r.getRootPath(), "hash"); if (!hash.exists()) return true; - FileSource as = new AssetsSource(r.getContext().getResources().getAssets()); + FileSource as = new AssetsSource(r.getResources().getAssets()); FileSource fs = new FileSource(); return !Utils.isContentsEquals(as, "hash", fs, hash.getPath()); } catch (IOException e) { return true; } + } + + public static void platformLog(String tag, String message) { + StringBuilder s = new StringBuilder(); + s.append("ms["); + s.append(System.currentTimeMillis()); + s.append("] "); + s.append(message); + android.util.Log.v(tag, s.toString()); } }