Java 类com.badlogic.gdx.tools.FileProcessor 实例源码

项目:gdx-texture-packer-gui    文件:PackingProcessor.java   
private static void deleteOldFiles(PackModel packModel) throws Exception {
    String filename = obtainFilename(packModel);

    TexturePacker.Settings settings = packModel.getSettings();
    String atlasExtension = settings.atlasExtension == null ? "" : settings.atlasExtension;
    atlasExtension = Pattern.quote(atlasExtension);

    for (int i = 0, n = settings.scale.length; i < n; i++) {
        FileProcessor deleteProcessor = new FileProcessor() {
            protected void processFile (Entry inputFile) throws Exception {
                Files.delete(inputFile.inputFile.toPath());
            }
        };
        deleteProcessor.setRecursive(false);

        String scaledPackFileName = settings.getScaledPackFileName(filename, i);
        File packFile = new File(scaledPackFileName);

        String prefix = filename;
        int dotIndex = prefix.lastIndexOf('.');
        if (dotIndex != -1) prefix = prefix.substring(0, dotIndex);
        deleteProcessor.addInputRegex("(?i)" + prefix + "\\d*\\.(png|jpg|jpeg|ktx|zktx)");
        deleteProcessor.addInputRegex("(?i)" + prefix + atlasExtension);

        File outputRoot = new File(packModel.getOutputDir());
        String dir = packFile.getParent();
        if (dir == null)
            deleteProcessor.process(outputRoot, null);
        else if (new File(outputRoot + "/" + dir).exists()) //
            deleteProcessor.process(outputRoot + "/" + dir, null);
    }
}
项目:GdxStudio    文件:TexturePackerFileProcessor.java   
public ArrayList<Entry> process (File[] files, File outputRoot) throws Exception {
    // Delete pack file and images.
    if (outputRoot.exists()) {
        new File(outputRoot, packFileName).delete();
        FileProcessor deleteProcessor = new FileProcessor() {
            protected void processFile (Entry inputFile) throws Exception {
                inputFile.inputFile.delete();
            }
        };
        deleteProcessor.setRecursive(false);

        String prefix = packFileName;
        int dotIndex = prefix.lastIndexOf('.');
        if (dotIndex != -1) prefix = prefix.substring(0, dotIndex);
        deleteProcessor.addInputRegex(Pattern.quote(prefix) + "\\d*\\.(png|jpg)");

        deleteProcessor.process(outputRoot, null);
    }
    return super.process(files, outputRoot);
}
项目:touhou-java    文件:TexturePackerFileProcessor.java   
public ArrayList<Entry> process (File[] files, File outputRoot) throws Exception {
    // Delete pack file and images.
    if (outputRoot.exists()) {
        new File(outputRoot, packFileName).delete();
        FileProcessor deleteProcessor = new FileProcessor() {
            protected void processFile (Entry inputFile) throws Exception {
                inputFile.inputFile.delete();
            }
        };
        deleteProcessor.setRecursive(false);

        String prefix = packFileName;
        int dotIndex = prefix.lastIndexOf('.');
        if (dotIndex != -1) prefix = prefix.substring(0, dotIndex);
        deleteProcessor.addInputRegex(Pattern.quote(prefix) + "\\d*\\.(png|jpg)");

        deleteProcessor.process(outputRoot, null);
    }
    return super.process(files, outputRoot);
}