Example usage for org.springframework.ide.eclipse.boot.wizard.content CodeSet.Processor CodeSet.Processor

List of usage examples for org.springframework.ide.eclipse.boot.wizard.content CodeSet.Processor CodeSet.Processor

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.wizard.content CodeSet.Processor CodeSet.Processor.

Prototype

CodeSet.Processor

Source Link

Usage

From source file:org.springframework.ide.eclipse.boot.wizard.content.CodeSet.java

/**
 * Copies the contents of codeset to a given filesystem location
 *///from  w  ww .ja  v  a2  s. c  om
public void createAt(final File location) throws Exception {
    if (location.exists()) {
        if (!FileUtils.deleteQuietly(location)) {
            throw new IOException("Data already exists at location and it could not be deleted: " + location);
        }
    }
    each(new CodeSet.Processor<Void>() {
        @Override
        public Void doit(CodeSetEntry e) throws Exception {
            IPath path = e.getPath();
            File target = new File(location, path.toString());
            if (e.isDirectory()) {
                target.mkdirs();
            } else {
                IOUtil.pipe(e.getData(), target);
                if (!IS_WINDOWS) {
                    int mode = e.getUnixMode();
                    if (mode > 0) {
                        Files.setPosixFilePermissions(target.toPath(), OsUtils.posixFilePermissions(mode));
                    }
                }
            }
            return null;
        }
    });
}