packages feed

buffer-pipe (empty) → 0.0

raw patch · 4 files changed

+82/−0 lines, 4 filesdep +basesetup-changed

Dependencies added: base

Files

+ LICENSE view
@@ -0,0 +1,26 @@+Copyright (c) 2015 Henning Thielemann+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:+1. Redistributions of source code must retain the above copyright+   notice, this list of conditions and the following disclaimer.+2. Redistributions in binary form must reproduce the above copyright+   notice, this list of conditions and the following disclaimer in the+   documentation and/or other materials provided with the distribution.+3. Neither the name of the University nor the names of its contributors+   may be used to endorse or promote products derived from this software+   without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF+SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,3 @@+#! /usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ buffer-pipe.cabal view
@@ -0,0 +1,36 @@+Name:           buffer-pipe+Version:        0.0+License:        BSD3+License-File:   LICENSE+Author:         Henning Thielemann <haskell@henning-thielemann.de>+Maintainer:     Henning Thielemann <haskell@henning-thielemann.de>+Category:       Console+Synopsis:       Read from stdin and write to stdout in large blocks+Description:+  Read from stdin and write to stdout in large blocks.+  This can be inserted in a chain of piping commands.+  E.g. if inserted after @tar c@ or before @tar x@+  you can reduce jumping forth and back on the hard disk.+  .+  You may also try the @buffer@ command+  from the Debian package of the same name.+Tested-With:    GHC==7.4.2+Cabal-Version:  >=1.6+Build-Type:     Simple++Source-Repository this+  Tag:         0.0+  Type:        darcs+  Location:    http://hub.darcs.net/thielema/buffer-pipe/++Source-Repository head+  Type:        darcs+  Location:    http://hub.darcs.net/thielema/buffer-pipe/++Executable buffer-pipe+  Build-Depends:+    base >= 4 && <5++  GHC-Options:    -Wall+  Hs-Source-Dirs: src+  Main-Is:        Main.hs
+ src/Main.hs view
@@ -0,0 +1,17 @@+module Main where++import qualified Foreign.Marshal.Alloc as Alloc+import qualified System.IO as IO+import Control.Monad (when)+++chunkSize :: Int+chunkSize = 100*1024*1024++main :: IO ()+main = Alloc.allocaBytes chunkSize $ \ptr ->+   let go = do+          readSize <- IO.hGetBuf IO.stdin ptr chunkSize+          IO.hPutBuf IO.stdout ptr readSize+          when (readSize >= chunkSize) go+   in  go