diff options
-rw-r--r-- | doc/note/bash/bash-on-windoof.txt | 6 | ||||
-rw-r--r-- | doc/note/gpg/gpg-windoof.txt | 5 | ||||
-rw-r--r-- | src/main/java/ch/hiddenalpha/unspecifiedgarbage/stream/StreamUtils.java | 15 |
3 files changed, 26 insertions, 0 deletions
diff --git a/doc/note/bash/bash-on-windoof.txt b/doc/note/bash/bash-on-windoof.txt new file mode 100644 index 0000000..32c0ee3 --- /dev/null +++ b/doc/note/bash/bash-on-windoof.txt @@ -0,0 +1,6 @@ + + +## Stop silly path replacements + + MSYS_NO_PATHCONV=1 ssh foo -- ls /var/lib + diff --git a/doc/note/gpg/gpg-windoof.txt b/doc/note/gpg/gpg-windoof.txt new file mode 100644 index 0000000..e883cbf --- /dev/null +++ b/doc/note/gpg/gpg-windoof.txt @@ -0,0 +1,5 @@ + + +[Why does git complain that no GPG agent is running?](https://superuser.com/a/1663941/1123359) + + diff --git a/src/main/java/ch/hiddenalpha/unspecifiedgarbage/stream/StreamUtils.java b/src/main/java/ch/hiddenalpha/unspecifiedgarbage/stream/StreamUtils.java index 889b3f1..bebe970 100644 --- a/src/main/java/ch/hiddenalpha/unspecifiedgarbage/stream/StreamUtils.java +++ b/src/main/java/ch/hiddenalpha/unspecifiedgarbage/stream/StreamUtils.java @@ -25,6 +25,21 @@ public class StreamUtils { return totalBytes; } + public static Runnable newCopyTask(java.io.InputStream src, java.io.OutputStream dst, boolean doCloseDst){ + return ()->{ + try{ + for( byte[] buf = new byte[8291] ;; ){ + int readLen = src.read(buf, 0, buf.length); + if( readLen == -1 ) break; + dst.write(buf, 0, readLen); + } + if( doCloseDst ) dst.close(); + }catch( java.io.IOException ex ){ + throw new RuntimeException(ex); + } + }; + } + public static <SRC,DST> java.util.Iterator<DST> map( java.util.Iterator<SRC> src , java.util.function.Function<SRC,DST> mapper ) { return new java.util.Iterator<DST>() { @Override public boolean hasNext() { return src.hasNext(); } |