Java Code Examples for org.gradle.api.file.FileVisitor#visitDir()

The following examples show how to use org.gradle.api.file.FileVisitor#visitDir() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TarFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitImpl(FileVisitor visitor, InputStream inputStream) throws IOException {
    AtomicBoolean stopFlag = new AtomicBoolean();
    NoCloseTarInputStream tar = new NoCloseTarInputStream(inputStream);
    TarEntry entry;
    while (!stopFlag.get() && (entry = tar.getNextEntry()) != null) {
        if (entry.isDirectory()) {
            visitor.visitDir(new DetailsImpl(entry, tar, stopFlag, chmod));
        } else {
            visitor.visitFile(new DetailsImpl(entry, tar, stopFlag, chmod));
        }
    }
}
 
Example 2
Source File: MapFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDirs(RelativePath path, FileVisitor visitor) {
    if (path == null || path.getParent() == null || !visitedDirs.add(path)) {
        return;
    }

    visitDirs(path.getParent(), visitor);
    visitor.visitDir(new FileVisitDetailsImpl(path, null, stopFlag, chmod));
}
 
Example 3
Source File: TarFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitImpl(FileVisitor visitor, InputStream inputStream) throws IOException {
    AtomicBoolean stopFlag = new AtomicBoolean();
    NoCloseTarInputStream tar = new NoCloseTarInputStream(inputStream);
    TarEntry entry;
    while (!stopFlag.get() && (entry = tar.getNextEntry()) != null) {
        if (entry.isDirectory()) {
            visitor.visitDir(new DetailsImpl(entry, tar, stopFlag, chmod));
        } else {
            visitor.visitFile(new DetailsImpl(entry, tar, stopFlag, chmod));
        }
    }
}
 
Example 4
Source File: MapFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDirs(RelativePath path, FileVisitor visitor) {
    if (path == null || path.getParent() == null || !visitedDirs.add(path)) {
        return;
    }

    visitDirs(path.getParent(), visitor);
    visitor.visitDir(new FileVisitDetailsImpl(path, null, stopFlag, chmod));
}
 
Example 5
Source File: ArchiveFileTree.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void visit(FileVisitor visitor) {
    if (!archiveFile.exists()) {
        throw new InvalidUserDataException(String.format("Cannot expand %s as it does not exist.", getDisplayName()));
    }
    if (!archiveFile.isFile()) {
        throw new InvalidUserDataException(String.format("Cannot expand %s as it is not a file.", getDisplayName()));
    }

    AtomicBoolean stopFlag = new AtomicBoolean();

    try {
        IS archiveInputStream = inputStreamProvider.openFile(archiveFile);
        try {
            ArchiveEntry archiveEntry;

            while (!stopFlag.get() && (archiveEntry = archiveInputStream.getNextEntry()) != null) {
                ArchiveEntryFileTreeElement details = createDetails(chmod);
                details.archiveInputStream = archiveInputStream;
                details.archiveEntry = (E) archiveEntry;
                details.stopFlag = stopFlag;

                try {
                    if (archiveEntry.isDirectory()) {
                        visitor.visitDir(details);
                    }
                    else {
                        visitor.visitFile(details);
                    }
                } finally {
                    details.close();
                }
            }
        } finally {
            archiveInputStream.close();
        }
    } catch (Exception e) {
        throw new GradleException(String.format("Could not expand %s.", getDisplayName()), e);
    }
}
 
Example 6
Source File: ArchiveFileTree.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void visit(FileVisitor visitor) {
    if (!archiveFile.exists()) {
        throw new InvalidUserDataException(String.format("Cannot expand %s as it does not exist.", getDisplayName()));
    }
    if (!archiveFile.isFile()) {
        throw new InvalidUserDataException(String.format("Cannot expand %s as it is not a file.", getDisplayName()));
    }

    AtomicBoolean stopFlag = new AtomicBoolean();

    try {
        IS archiveInputStream = inputStreamProvider.openFile(archiveFile);
        try {
            ArchiveEntry archiveEntry;

            while (!stopFlag.get() && (archiveEntry = archiveInputStream.getNextEntry()) != null) {
                ArchiveEntryFileTreeElement details = createDetails(chmod);
                details.archiveInputStream = archiveInputStream;
                details.archiveEntry = (E) archiveEntry;
                details.stopFlag = stopFlag;

                try {
                    if (archiveEntry.isDirectory()) {
                        visitor.visitDir(details);
                    }
                    else {
                        visitor.visitFile(details);
                    }
                } finally {
                    details.close();
                }
            }
        } finally {
            archiveInputStream.close();
        }
    } catch (Exception e) {
        throw new GradleException(String.format("Could not expand %s.", getDisplayName()), e);
    }
}
 
Example 7
Source File: TarFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitImpl(FileVisitor visitor, InputStream inputStream) throws IOException {
    AtomicBoolean stopFlag = new AtomicBoolean();
    NoCloseTarInputStream tar = new NoCloseTarInputStream(inputStream);
    TarEntry entry;
    while (!stopFlag.get() && (entry = tar.getNextEntry()) != null) {
        if (entry.isDirectory()) {
            visitor.visitDir(new DetailsImpl(entry, tar, stopFlag, chmod));
        } else {
            visitor.visitFile(new DetailsImpl(entry, tar, stopFlag, chmod));
        }
    }
}
 
Example 8
Source File: MapFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDirs(RelativePath path, FileVisitor visitor) {
    if (path == null || path.getParent() == null || !visitedDirs.add(path)) {
        return;
    }

    visitDirs(path.getParent(), visitor);
    visitor.visitDir(new FileVisitDetailsImpl(path, null, stopFlag, chmod));
}
 
Example 9
Source File: TarFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitImpl(FileVisitor visitor, InputStream inputStream) throws IOException {
    AtomicBoolean stopFlag = new AtomicBoolean();
    NoCloseTarInputStream tar = new NoCloseTarInputStream(inputStream);
    TarEntry entry;
    while (!stopFlag.get() && (entry = tar.getNextEntry()) != null) {
        if (entry.isDirectory()) {
            visitor.visitDir(new DetailsImpl(entry, tar, stopFlag, chmod));
        } else {
            visitor.visitFile(new DetailsImpl(entry, tar, stopFlag, chmod));
        }
    }
}
 
Example 10
Source File: MapFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDirs(RelativePath path, FileVisitor visitor) {
    if (path == null || path.getParent() == null || !visitedDirs.add(path)) {
        return;
    }

    visitDirs(path.getParent(), visitor);
    visitor.visitDir(new FileVisitDetailsImpl(path, null, stopFlag, chmod));
}