first
This commit is contained in:
commit
a3b253ce0c
8 changed files with 315 additions and 0 deletions
27
main/ips.hs
Normal file
27
main/ips.hs
Normal file
|
@ -0,0 +1,27 @@
|
|||
module Main (main) where
|
||||
|
||||
import IPS (Bytes, makeBytes)
|
||||
import qualified IPS
|
||||
import System.Environment
|
||||
import System.IO
|
||||
import qualified Data.ByteString as ByteString
|
||||
import qualified Data.Vector.Storable as Vector
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
args <- getArgs
|
||||
case args of
|
||||
[inf, ipsf, outf] -> do
|
||||
buf <- readBytes inf
|
||||
ips <- either error id <$> IPS.read ipsf
|
||||
writeBytes outf $ IPS.apply ips buf
|
||||
_ -> error "usage: $0 <in> <ips> <out>"
|
||||
|
||||
readBytes :: FilePath -> IO Bytes
|
||||
readBytes f = makeBytes <$> ByteString.readFile f
|
||||
|
||||
writeBytes :: FilePath -> Bytes -> IO ()
|
||||
writeBytes f buf =
|
||||
withFile f WriteMode \h ->
|
||||
Vector.unsafeWith buf \ptr ->
|
||||
hPutBuf h ptr (Vector.length buf)
|
Loading…
Add table
Add a link
Reference in a new issue