private static byte[] readFully(InputStream is) throws IOException { try (TemporaryBuffer b = new TemporaryBuffer.Heap(Integer.MAX_VALUE)) { b.copy(is); return b.toByteArray(); } }
@Override public byte[] toByteArray() throws IOException { if (onDiskFile == null) { return super.toByteArray(); } final long len = length(); if (Integer.MAX_VALUE < len) throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize); final byte[] out = new byte[(int) len]; try (FileInputStream in = new FileInputStream(onDiskFile)) { IO.readFully(in, out, 0, (int) len); } return out; }
private String[] extractFileLines(Charset[] csGuess) { final TemporaryBuffer[] tmp = new TemporaryBuffer[getParentCount() + 1]; try { for (int i = 0; i < tmp.length; i++) tmp[i] = new TemporaryBuffer.Heap(Integer.MAX_VALUE); for (HunkHeader h : getHunks()) h.extractFileLines(tmp); final String[] r = new String[tmp.length]; for (int i = 0; i < tmp.length; i++) { Charset cs = csGuess != null ? csGuess[i] : null; if (cs == null) { cs = UTF_8; } r[i] = RawParseUtils.decode(cs, tmp[i].toByteArray()); } return r; } catch (IOException ioe) { throw new RuntimeException(JGitText.get().cannotConvertScriptToText, ioe); } }
checkoutMetadata.smudgeFilterCommand, entry.getPathString(), result.getStdout().toByteArray(MAX_EXCEPTION_TEXT_SIZE), RawParseUtils.decode(result.getStderr() .toByteArray(MAX_EXCEPTION_TEXT_SIZE))));
throw new IOException(new FilterFailedException(rc, filterCommand, getEntryPathString(), result.getStdout().toByteArray(MAX_EXCEPTION_TEXT_SIZE), RawParseUtils.decode(result.getStderr() .toByteArray(MAX_EXCEPTION_TEXT_SIZE))));
private static byte[] readFully(InputStream is) throws IOException { try (TemporaryBuffer b = new TemporaryBuffer.Heap(Integer.MAX_VALUE)) { b.copy(is); return b.toByteArray(); } }
public byte[] toByteArray() throws IOException { if (onDiskFile == null) { return super.toByteArray(); } final long len = length(); if (Integer.MAX_VALUE < len) throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize); final byte[] out = new byte[(int) len]; final FileInputStream in = new FileInputStream(onDiskFile); try { IO.readFully(in, out, 0, (int) len); } finally { in.close(); } return out; }
@Override public byte[] toByteArray() throws IOException { if (onDiskFile == null) { return super.toByteArray(); } final long len = length(); if (Integer.MAX_VALUE < len) throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize); final byte[] out = new byte[(int) len]; try (FileInputStream in = new FileInputStream(onDiskFile)) { IO.readFully(in, out, 0, (int) len); } return out; }
private static byte[] readFully(final InputStream is) throws IOException { TemporaryBuffer b = new TemporaryBuffer.Heap(Integer.MAX_VALUE); b.copy(is); b.close(); return b.toByteArray(); }
private String[] extractFileLines(final Charset[] csGuess) { final TemporaryBuffer[] tmp = new TemporaryBuffer[getParentCount() + 1]; try { for (int i = 0; i < tmp.length; i++) tmp[i] = new TemporaryBuffer.Heap(Integer.MAX_VALUE); for (final HunkHeader h : getHunks()) h.extractFileLines(tmp); final String[] r = new String[tmp.length]; for (int i = 0; i < tmp.length; i++) { Charset cs = csGuess != null ? csGuess[i] : null; if (cs == null) cs = Constants.CHARSET; r[i] = RawParseUtils.decode(cs, tmp[i].toByteArray()); } return r; } catch (IOException ioe) { throw new RuntimeException(JGitText.get().cannotConvertScriptToText, ioe); } }
private String[] extractFileLines(Charset[] csGuess) { final TemporaryBuffer[] tmp = new TemporaryBuffer[getParentCount() + 1]; try { for (int i = 0; i < tmp.length; i++) tmp[i] = new TemporaryBuffer.Heap(Integer.MAX_VALUE); for (HunkHeader h : getHunks()) h.extractFileLines(tmp); final String[] r = new String[tmp.length]; for (int i = 0; i < tmp.length; i++) { Charset cs = csGuess != null ? csGuess[i] : null; if (cs == null) { cs = UTF_8; } r[i] = RawParseUtils.decode(cs, tmp[i].toByteArray()); } return r; } catch (IOException ioe) { throw new RuntimeException(JGitText.get().cannotConvertScriptToText, ioe); } }
checkoutMetadata.smudgeFilterCommand, entry.getPathString(), result.getStdout().toByteArray(MAX_EXCEPTION_TEXT_SIZE), RawParseUtils.decode(result.getStderr() .toByteArray(MAX_EXCEPTION_TEXT_SIZE))));
private InputStream filterClean(InputStream in, OperationType opType) throws IOException { in = handleAutoCRLF(in, opType); String filterCommand = getCleanFilterCommand(); if (filterCommand != null) { FS fs = repository.getFS(); ProcessBuilder filterProcessBuilder = fs.runInShell(filterCommand, new String[0]); filterProcessBuilder.directory(repository.getWorkTree()); filterProcessBuilder.environment().put(Constants.GIT_DIR_KEY, repository.getDirectory().getAbsolutePath()); ExecutionResult result; try { result = fs.execute(filterProcessBuilder, in); } catch (IOException | InterruptedException e) { throw new IOException(new FilterFailedException(e, filterCommand, getEntryPathString())); } int rc = result.getRc(); if (rc != 0) { throw new IOException(new FilterFailedException(rc, filterCommand, getEntryPathString(), result.getStdout().toByteArray(MAX_EXCEPTION_TEXT_SIZE), RawParseUtils.decode(result.getStderr() .toByteArray(MAX_EXCEPTION_TEXT_SIZE)))); } return result.getStdout().openInputStream(); } return in; }
throw new IOException(new FilterFailedException(rc, filterCommand, getEntryPathString(), result.getStdout().toByteArray(MAX_EXCEPTION_TEXT_SIZE), RawParseUtils.decode(result.getStderr() .toByteArray(MAX_EXCEPTION_TEXT_SIZE))));
checkoutMetadata.smudgeFilterCommand, entry.getPathString(), result.getStdout().toByteArray(MAX_EXCEPTION_TEXT_SIZE), RawParseUtils.decode(result.getStderr() .toByteArray(MAX_EXCEPTION_TEXT_SIZE))));