FTPLine 1.4.0.0 → 1.4.1.1
raw patch · 3 files changed
+18/−7 lines, 3 files
Files
- FTPLine.cabal +1/−1
- Main.hs +16/−5
- license +1/−1
FTPLine.cabal view
@@ -1,5 +1,5 @@ Name: FTPLine -Version: 1.4.0.0 +Version: 1.4.1.1 Cabal-Version: >= 1.6 License: BSD3 License-file: license
Main.hs view
@@ -2,7 +2,9 @@ {-# LANGUAGE FlexibleInstances #-} module Main (main) where+ import Data.Maybe+import Data.Char (ord, chr) import qualified Data.Strict.Maybe as Strict import Control.Monad.State.Strict import System.Console.Haskeline hiding (getInputLine)@@ -13,11 +15,11 @@ import Network.FTP.Client.Parser import System.Directory import Control.Applicative ((<$>))-import Data.List (intercalate)+import Data.List (intercalate,isPrefixOf) import System.Console.ANSI import System.IO import System.Environment (getArgs)-import qualified Data.ByteString.Char8 as B+import qualified Data.ByteString.Lazy as B import Paths_FTPLine (version) import Data.Version (showVersion) @@ -36,8 +38,17 @@ getInputLine_ :: String -> String -> FTPLine () getInputLine_ str com = do withColor Yellow $ outputStr str- outputStrLn com+ outputStrLn $ processInteractiveOutput com +processInteractiveOutput :: String -> String+processInteractiveOutput str+ | "login" `isPrefixOf` str+ = let ws = words str+ in if length ws == 3+ then unwords $ take 2 ws ++ [fmap (\_ -> '*') (ws !! 2)]+ else str+ | otherwise = str+ data File = File FilePath !B.ByteString type SMaybe = Strict.Maybe@@ -211,7 +222,7 @@ <-> \ c -> do (x, r) <- liftIO $ getbinary c fp- newFile $ File fp $ B.pack x+ newFile $ File fp $ B.pack $ fmap (fromIntegral . ord) x return r download :: String -> FTPLine FTPResult@@ -229,7 +240,7 @@ do x <- getFile if Strict.isNothing x then ftperror "File memory empty." else let (File _ cnt) = Strict.fromJust x in- liftIO $ putbinary c fp $ B.unpack cnt+ liftIO $ putbinary c fp $ fmap (chr . fromIntegral) $ B.unpack cnt upload :: String -> FTPLine FTPResult upload fp = withConnection $ \ c -> liftIO $ uploadbinary c fp
license view
@@ -1,4 +1,4 @@-Copyright (c)2011, Daniel Díaz +Copyright (c)2016, Daniel Díaz All rights reserved.