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

The following examples show how to use org.gradle.api.file.FileVisitor#visitFile() . 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: 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 3
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 4
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 5
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 6
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 7
Source File: SingletonFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void visit(FileVisitor visitor) {
    visitor.visitFile(new DefaultFileVisitDetails(file, new RelativePath(true, file.getName()), new AtomicBoolean(), fileSystem, fileSystem));
}
 
Example 8
Source File: SingletonFileTree.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void visit(FileVisitor visitor) {
    visitor.visitFile(new DefaultFileVisitDetails(file, new RelativePath(true, file.getName()), new AtomicBoolean(), fileSystem, fileSystem));
}
 
Example 9
Source File: SingletonFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void visit(FileVisitor visitor) {
    visitor.visitFile(new DefaultFileVisitDetails(file, new RelativePath(true, file.getName()), new AtomicBoolean(), fileSystem, fileSystem));
}
 
Example 10
Source File: SingletonFileTree.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void visit(FileVisitor visitor) {
    visitor.visitFile(new DefaultFileVisitDetails(file, new RelativePath(true, file.getName()), new AtomicBoolean(), fileSystem, fileSystem));
}