Example usage for org.eclipse.jgit.util.io AutoCRLFInputStream AutoCRLFInputStream

List of usage examples for org.eclipse.jgit.util.io AutoCRLFInputStream AutoCRLFInputStream

Introduction

In this page you can find the example usage for org.eclipse.jgit.util.io AutoCRLFInputStream AutoCRLFInputStream.

Prototype

public AutoCRLFInputStream(InputStream in, boolean detectBinary) 

Source Link

Document

Creates a new InputStream, wrapping the specified stream

Usage

From source file:jetbrains.buildServer.buildTriggers.vcs.git.patch.LoadContentAction.java

License:Apache License

private long getStreamSize(@NotNull GitVcsRoot root, @NotNull ObjectLoader loader) throws IOException {
    if (!root.isAutoCrlf())
        return loader.getSize();

    InputStream objectStream = null;
    try {//w w  w  .j av  a  2s .c o  m
        objectStream = openContentStream(loader);
        objectStream = new AutoCRLFInputStream(objectStream, true);
        int count;
        int size = 0;
        byte[] buf = new byte[8096];
        while ((count = objectStream.read(buf)) != -1) {
            size += count;
        }
        return size;
    } finally {
        if (objectStream != null)
            objectStream.close();
    }
}

From source file:jetbrains.buildServer.buildTriggers.vcs.git.patch.LoadContentAction.java

License:Apache License

@NotNull
private InputStream getObjectStream(@NotNull final GitVcsRoot root, @NotNull final ObjectLoader loader)
        throws IOException {
    final InputStream stream = openContentStream(loader);
    if (!root.isAutoCrlf())
        return stream;
    return new AutoCRLFInputStream(stream, true);
}

From source file:org.eclipse.egit.core.storage.GitBlobStorage.java

License:Open Source License

private InputStream open() throws IOException, CoreException, IncorrectObjectTypeException {
    if (blobId == null)
        return new ByteArrayInputStream(new byte[0]);

    try {//from  w  w  w . j ava2 s.  c  o m
        WorkingTreeOptions workingTreeOptions = db.getConfig().get(WorkingTreeOptions.KEY);
        final InputStream objectInputStream = db.open(blobId, Constants.OBJ_BLOB).openStream();
        switch (workingTreeOptions.getAutoCRLF()) {
        case INPUT:
            // When autocrlf == input the working tree could be either CRLF or LF, i.e. the comparison
            // itself should ignore line endings.
        case FALSE:
            return objectInputStream;
        case TRUE:
        default:
            return new AutoCRLFInputStream(objectInputStream, true);
        }
    } catch (MissingObjectException notFound) {
        throw new CoreException(
                Activator.error(NLS.bind(CoreText.BlobStorage_blobNotFound, blobId.name(), path), notFound));
    }
}