public void File_list( string path, ystring ydirectory, ystring yfile, string sskip = "0", string stake = "10", ystring done = null) { var DIRECTORY_DCIM = android.os.Environment.DIRECTORY_DCIM; path = android.os.Environment.getExternalStoragePublicDirectory(DIRECTORY_DCIM).getAbsolutePath(); path += "/Camera"; var f = new File(path); var a = f.list(); foreach (var item in a) { if (new File(path + "/" + item).isDirectory()) ydirectory(path + "/" + item); } int skip = int.Parse(sskip); int take = int.Parse(stake); foreach (var item in a) { if (skip > 0) { skip--; } else { if (take > 0) { take--; if (new File(path + "/" + item).isFile()) yfile(path + "/" + item); } else { break; } } } done(""); }
public int run(String[] arguments) { sourceFiles.clear(); if (!handleArguments(arguments)) { return 1; } var t0 = System.nanoTime(); try { var results = new Compiler().compileFromFiles(parameters, sourceFiles.toArray(new File[sourceFiles.size()])); var hasErrors = false; foreach (var error in results.Errors) { var filename = error.Filename; if (filename != null) { System.out.print(new File(error.Filename).getAbsolutePath()); } else { System.out.print("Unknown source"); } if (error.Line > 0) { System.out.print(" ("); System.out.print(error.Line); if (error.Column > 0) { System.out.print(", "); System.out.print(error.Column); } System.out.print(")"); } if (error.Level == 0) { hasErrors = true; System.out.print(" error "); } else { System.out.print(" warning "); } System.out.print(error.Id); System.out.print(": "); System.out.println(error.Message); } if (!hasErrors) { var outputFile = new File(outputPath); if (outputFile.isDirectory() || outputPath.endsWith("\\") || outputPath.endsWith("/")) { foreach (var e in results.ClassFiles.entrySet()) { var file = new File(outputFile, e.Key.replace('.', '/') + ".class"); var dir = file.getParentFile(); if (!dir.exists()) { dir.mkdirs(); } using (var s = new FileOutputStream(file)) { s.write(e.Value); } } } else { var destination = outputPath; if (PathHelper.getExtension(destination).length() == 0) { destination += ".jar"; } using (var zipStream = new ZipOutputStream(new FileOutputStream(destination))) { if (manifestPath != null) { var zipEntry = new ZipEntry("META-INF/MANIFEST.MF"); zipStream.putNextEntry(zipEntry); var buffer = new byte[4096]; var inputStream = new FileInputStream(manifestPath); int read; while ((read = inputStream.read(buffer)) != -1) { zipStream.write(buffer, 0, read); } inputStream.close(); } if (resourcesPath != null) { var rootDir = new File(resourcesPath); foreach (var content in rootDir.list()) { var file = new File(rootDir, content); if (file.isDirectory()) { exploreDirectory(zipStream, "", file); } else { addEntry(zipStream, "", file); } } } foreach (var e in results.ClassFiles.entrySet()) { var zipEntry = new ZipEntry(e.Key.replace('.', '/') + ".class"); zipStream.putNextEntry(zipEntry); zipStream.write(e.Value); } } } System.out.println(); System.out.println(String.format("%d class(es) successfully generated in %.2fs", results.classFiles.size(), (System.nanoTime() - t0) / 1e9)); return 0; } else { System.out.println(); System.out.println("Compilation failed"); return 1; } } catch (TypeLoadException e) { System.out.println("Cannot find type " + e.TypeName + ". The class is missing from the classpath."); System.out.println("Compilation failed"); return 1; } }
private void exploreDirectory(ZipOutputStream zipStream, String root, File directory) { if (directory.isHidden()) { return; } foreach (var content in directory.list()) { var file = new File(directory, content); if (file.isDirectory()) { exploreDirectory(zipStream, root + directory.getName() + '/', file); } else { addEntry(zipStream, root + directory.getName() + '/', file); } } }
public void File_list(string path, Action<string> ydirectory, Action<string> yfile) { // can we have stats for this method as per /jsc ? // or even better record fuull profiler trace? // D/dalvikvm( 8969): GC_FOR_MALLOC freed 710K, 46% free 7037K/12871K, external 2390K/2985K, paused 27ms var f = new File(path); var a = f.list(); foreach (var item in a) { if (new File(path + "/" + item).isDirectory()) ydirectory(item); } foreach (var item in a) { if (new File(path + "/" + item).isFile()) yfile(item); } }