/** Copies this file or directory to the specified file or directory. If this handle is a file, then 1) if the destination is a * file, it is overwritten, or 2) if the destination is a directory, this file is copied into it, or 3) if the destination * doesn't exist, {@link #mkdirs()} is called on the destination's parent and this file is copied into it with a new name. If * this handle is a directory, then 1) if the destination is a file, RuntimeException is thrown, or 2) if the destination is a * directory, this directory is copied recursively into it as a subdirectory, overwriting existing files, or 3) if the * destination doesn't exist, {@link #mkdirs()} is called on the destination and this directory is copied recursively into it * as a subdirectory. * @throw RuntimeException if the destination file handle is a {@link FileType#Classpath} or FileType#Internal file, or copying * failed. */ public void copyTo (FileDescriptor dest) { if (!isDirectory()) { if (dest.isDirectory()) dest = dest.child(name()); copyFile(this, dest); return; } if (dest.exists()) { if (!dest.isDirectory()) throw new RuntimeException("Destination exists but is not a directory: " + dest); } else { dest.mkdirs(); if (!dest.isDirectory()) throw new RuntimeException("Destination directory cannot be created: " + dest); } dest = dest.child(name()); copyDirectory(this, dest); }
/** Copies this file or directory to the specified file or directory. If this handle is a file, then 1) if the destination is a * file, it is overwritten, or 2) if the destination is a directory, this file is copied into it, or 3) if the destination * doesn't exist, {@link #mkdirs()} is called on the destination's parent and this file is copied into it with a new name. If * this handle is a directory, then 1) if the destination is a file, RuntimeException is thrown, or 2) if the destination is a * directory, this directory is copied recursively into it as a subdirectory, overwriting existing files, or 3) if the * destination doesn't exist, {@link #mkdirs()} is called on the destination and this directory is copied recursively into it * as a subdirectory. * @throw RuntimeException if the destination file handle is a {@link FileType#Classpath} or FileType#Internal file, or copying * failed. */ public void copyTo (FileDescriptor dest) { if (!isDirectory()) { if (dest.isDirectory()) dest = dest.child(name()); copyFile(this, dest); return; } if (dest.exists()) { if (!dest.isDirectory()) throw new RuntimeException("Destination exists but is not a directory: " + dest); } else { dest.mkdirs(); if (!dest.isDirectory()) throw new RuntimeException("Destination directory cannot be created: " + dest); } dest = dest.child(name()); copyDirectory(this, dest); }
static private void copyDirectory (FileDescriptor sourceDir, FileDescriptor destDir) { destDir.mkdirs(); FileDescriptor[] files = sourceDir.list(); for (int i = 0, n = files.length; i < n; i++) { FileDescriptor srcFile = files[i]; FileDescriptor destFile = destDir.child(srcFile.name()); if (srcFile.isDirectory()) copyDirectory(srcFile, destFile); else copyFile(srcFile, destFile); } } }
static private void copyDirectory (FileDescriptor sourceDir, FileDescriptor destDir) { destDir.mkdirs(); FileDescriptor[] files = sourceDir.list(); for (int i = 0, n = files.length; i < n; i++) { FileDescriptor srcFile = files[i]; FileDescriptor destFile = destDir.child(srcFile.name()); if (srcFile.isDirectory()) copyDirectory(srcFile, destFile); else copyFile(srcFile, destFile); } } }
private void generateCppFile (ArrayList<JavaSegment> javaSegments, FileDescriptor hFile, FileDescriptor cppFile) throws Exception { String headerFileContent = hFile.readString(); ArrayList<CMethod> cMethods = cMethodParser.parse(headerFileContent).getMethods(); StringBuffer buffer = new StringBuffer(); emitHeaderInclude(buffer, hFile.name()); for (JavaSegment segment : javaSegments) { if (segment instanceof JniSection) { emitJniSection(buffer, (JniSection)segment); } if (segment instanceof JavaMethod) { JavaMethod javaMethod = (JavaMethod)segment; if (javaMethod.getNativeCode() == null) { throw new RuntimeException("Method '" + javaMethod.getName() + "' has no body"); } CMethod cMethod = findCMethod(javaMethod, cMethods); if (cMethod == null) throw new RuntimeException("Couldn't find C method for Java method '" + javaMethod.getClassName() + "#" + javaMethod.getName() + "'"); emitJavaMethod(buffer, javaMethod, cMethod); } } cppFile.writeString(buffer.toString(), false, "UTF-8"); }
private void generateCppFile (ArrayList<JavaSegment> javaSegments, FileDescriptor hFile, FileDescriptor cppFile) throws Exception { String headerFileContent = hFile.readString(); ArrayList<CMethod> cMethods = cMethodParser.parse(headerFileContent).getMethods(); StringBuffer buffer = new StringBuffer(); emitHeaderInclude(buffer, hFile.name()); for (JavaSegment segment : javaSegments) { if (segment instanceof JniSection) { emitJniSection(buffer, (JniSection)segment); } if (segment instanceof JavaMethod) { JavaMethod javaMethod = (JavaMethod)segment; if (javaMethod.getNativeCode() == null) { throw new RuntimeException("Method '" + javaMethod.getName() + "' has no body"); } CMethod cMethod = findCMethod(javaMethod, cMethods); if (cMethod == null) throw new RuntimeException("Couldn't find C method for Java method '" + javaMethod.getClassName() + "#" + javaMethod.getName() + "'"); emitJavaMethod(buffer, javaMethod, cMethod); } } cppFile.writeString(buffer.toString(), false, "UTF-8"); }
} else { if (file.extension().equals("java")) { if (file.name().contains("NativeCodeGenerator")) continue; if (includes != null && !matcher.match(file.path(), includes)) continue; if (excludes != null && matcher.match(file.path(), excludes)) continue;
} else { if (file.extension().equals("java")) { if (file.name().contains("NativeCodeGenerator")) continue; if (includes != null && !matcher.match(file.path(), includes)) continue; if (excludes != null && matcher.match(file.path(), excludes)) continue;
/** Copies this file or directory to the specified file or directory. If this handle is a file, then 1) if the destination is a * file, it is overwritten, or 2) if the destination is a directory, this file is copied into it, or 3) if the destination * doesn't exist, {@link #mkdirs()} is called on the destination's parent and this file is copied into it with a new name. If * this handle is a directory, then 1) if the destination is a file, RuntimeException is thrown, or 2) if the destination is a * directory, this directory is copied recursively into it as a subdirectory, overwriting existing files, or 3) if the * destination doesn't exist, {@link #mkdirs()} is called on the destination and this directory is copied recursively into it * as a subdirectory. * @throw RuntimeException if the destination file handle is a {@link FileType#Classpath} or FileType#Internal file, or copying * failed. */ public void copyTo (FileDescriptor dest) { if (!isDirectory()) { if (dest.isDirectory()) dest = dest.child(name()); copyFile(this, dest); return; } if (dest.exists()) { if (!dest.isDirectory()) throw new RuntimeException("Destination exists but is not a directory: " + dest); } else { dest.mkdirs(); if (!dest.isDirectory()) throw new RuntimeException("Destination directory cannot be created: " + dest); } dest = dest.child(name()); copyDirectory(this, dest); }
static private void copyDirectory (FileDescriptor sourceDir, FileDescriptor destDir) { destDir.mkdirs(); FileDescriptor[] files = sourceDir.list(); for (int i = 0, n = files.length; i < n; i++) { FileDescriptor srcFile = files[i]; FileDescriptor destFile = destDir.child(srcFile.name()); if (srcFile.isDirectory()) copyDirectory(srcFile, destFile); else copyFile(srcFile, destFile); } } }
private void generateCppFile (ArrayList<JavaSegment> javaSegments, FileDescriptor hFile, FileDescriptor cppFile) throws Exception { String headerFileContent = hFile.readString(); ArrayList<CMethod> cMethods = cMethodParser.parse(headerFileContent).getMethods(); StringBuffer buffer = new StringBuffer(); emitHeaderInclude(buffer, hFile.name()); for (JavaSegment segment : javaSegments) { if (segment instanceof JniSection) { emitJniSection(buffer, (JniSection)segment); } if (segment instanceof JavaMethod) { JavaMethod javaMethod = (JavaMethod)segment; if (javaMethod.getNativeCode() == null) { throw new RuntimeException("Method '" + javaMethod.getName() + "' has no body"); } CMethod cMethod = findCMethod(javaMethod, cMethods); if (cMethod == null) throw new RuntimeException("Couldn't find C method for Java method '" + javaMethod.getClassName() + "#" + javaMethod.getName() + "'"); emitJavaMethod(buffer, javaMethod, cMethod); } } cppFile.writeString(buffer.toString(), false, "UTF-8"); }
} else { if (file.extension().equals("java")) { if (file.name().contains("NativeCodeGenerator")) continue; if (includes != null && !matcher.match(file.path(), includes)) continue; if (excludes != null && matcher.match(file.path(), excludes)) continue;