use of com.google.security.zynamics.zylib.io.IDirectoryTraversalCallback in project binnavi by google.
the class PluginLoader method collectPluginFiles.
/**
* Collects all plugin files from the plugin directory.
*
* @param directory The plugin directory.
*
* @return The collected plugin files.
*/
public static Set<File> collectPluginFiles(final String directory) {
final Set<File> pluginFiles = new HashSet<File>();
final File file = new File(directory);
DirUtils.traverse(file, new IDirectoryTraversalCallback() {
@Override
public void entering(final File directory) {
System.out.println(directory.getName());
// Unused
}
@Override
public void leaving(final File directory) {
// Unused
}
@Override
public void nextFile(final File pluginFile) {
System.out.println(pluginFile.getName());
if (pluginFile.getName().endsWith(".jar") || pluginFile.getName().endsWith(".class")) {
pluginFiles.add(pluginFile);
}
}
});
return pluginFiles;
}
use of com.google.security.zynamics.zylib.io.IDirectoryTraversalCallback in project binnavi by google.
the class JarLoader method collectJars.
/**
* Finds the JAR files in the additional JAR file directory.
*
* @param rootPath The BinNavi root path.
*
* @return The list of JAR files found.
*/
public static Set<File> collectJars(final String rootPath) {
Preconditions.checkNotNull(rootPath, "IE00827: BinNavi root path can't be null");
final Set<File> jarFiles = Sets.newHashSet();
final File jarDirectory = new File(rootPath + File.separator + JAR_DIRECTORY);
DirUtils.traverse(jarDirectory, new IDirectoryTraversalCallback() {
@Override
public void entering(final File directory) {
// Not necessary
}
@Override
public void leaving(final File directory) {
// Not necessary
}
@Override
public void nextFile(final File file) {
if (!FileUtils.getFileExtension(file).equals("jar")) {
return;
}
jarFiles.add(file);
}
});
return jarFiles;
}
use of com.google.security.zynamics.zylib.io.IDirectoryTraversalCallback in project binnavi by google.
the class CTutorialLoader method readTutorials.
/**
* Loads all tutorial files from the given directory.
*
* @param directory Directory from which the tutorials are loaded.
*
* @return List of tutorials loaded from the tutorial files in the given directory.
*/
public static IFilledList<CTutorial> readTutorials(final String directory) {
final IFilledList<CTutorial> tutorials = new FilledList<CTutorial>();
DirUtils.traverse(new File(directory), new IDirectoryTraversalCallback() {
@Override
public void entering(final File directory) {
// Irrelevant
}
@Override
public void leaving(final File directory) {
// Irrelevant
}
@Override
public void nextFile(final File file) {
if (file.getAbsolutePath().endsWith("xml")) {
try {
tutorials.add(loadTutorial(file));
} catch (final ParserConfigurationException e) {
CUtilityFunctions.logException(e);
} catch (final SAXException e) {
CUtilityFunctions.logException(e);
} catch (final IOException e) {
CUtilityFunctions.logException(e);
}
}
}
});
return tutorials;
}
use of com.google.security.zynamics.zylib.io.IDirectoryTraversalCallback in project binnavi by google.
the class ScriptLoader method collectScripts.
/**
* Collects all script files that can be found in the default scripts directory.
*
* @param startupPath BinNavi startup path.
*
* @return Script files found in the scripts path.
*/
public static Set<File> collectScripts(final String startupPath) {
final Set<File> scriptFiles = new HashSet<>();
final String scriptPath = startupPath + File.separator + "scripts";
final File scriptDir = new File(scriptPath);
DirUtils.traverse(scriptDir, new IDirectoryTraversalCallback() {
private boolean skip = false;
@Override
public void entering(final File directory) {
skip = isLibDirectory(scriptDir, directory);
}
@Override
public void leaving(final File directory) {
skip = false;
}
@Override
public void nextFile(final File file) {
if (skip) {
return;
}
final String filename = FileUtils.getFileBasename(file);
if ("init".equals(filename) || !ScriptRunner.canRun(file)) {
return;
}
scriptFiles.add(file);
}
});
return scriptFiles;
}
Aggregations