more OsPath conversion (602/749)
Sponsored-by: Brock Spratlen
This commit is contained in:
parent
2d1db7986c
commit
a5d48edd94
25 changed files with 227 additions and 187 deletions
|
@ -13,7 +13,10 @@
|
|||
|
||||
module Utility.OsString (
|
||||
module X,
|
||||
length
|
||||
length,
|
||||
#ifndef WITH_OSPATH
|
||||
toChar,
|
||||
#endif
|
||||
) where
|
||||
|
||||
#ifdef WITH_OSPATH
|
||||
|
@ -30,4 +33,10 @@ length = B.length . fromOsPath
|
|||
#else
|
||||
import Data.ByteString as X hiding (length)
|
||||
import Data.ByteString (length)
|
||||
import Data.Char
|
||||
import Data.Word
|
||||
import Prelude (fromIntegral, (.))
|
||||
|
||||
toChar :: Word8 -> Char
|
||||
toChar = chr . fromIntegral
|
||||
#endif
|
||||
|
|
|
@ -17,6 +17,11 @@ module Utility.SafeOutput (
|
|||
import Data.Char
|
||||
import qualified Data.ByteString as S
|
||||
|
||||
#ifdef WITH_OSPATH
|
||||
import qualified Utility.OsString as OS
|
||||
import Utility.OsPath
|
||||
#endif
|
||||
|
||||
class SafeOutputtable t where
|
||||
safeOutput :: t -> t
|
||||
|
||||
|
@ -26,6 +31,11 @@ instance SafeOutputtable String where
|
|||
instance SafeOutputtable S.ByteString where
|
||||
safeOutput = S.filter (safeOutputChar . chr . fromIntegral)
|
||||
|
||||
#ifdef WITH_OSPATH
|
||||
instance SafeOutputtable OsString where
|
||||
safeOutput = OS.filter (safeOutputChar . toChar)
|
||||
#endif
|
||||
|
||||
safeOutputChar :: Char -> Bool
|
||||
safeOutputChar c
|
||||
| not (isControl c) = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue