
By using System.Directory.OsPath, which takes and returns OsString, which is a ShortByteString. So, things like dirContents currently have the overhead of copying that to a ByteString, but that should be less than the overhead of using Strings which often in turn were converted to RawFilePaths. Added Utility.OsString and the OsString build flag. That flag is turned on in the stack.yaml, and will be turned on automatically by cabal when built with new enough libraries. The stack.yaml change is a bit ugly, and that could be reverted for now if it causes any problems. Note that Utility.OsString.toOsString on windows is avoiding only a check of encoding that is documented as being unlikely to fail. I don't think it can fail in git-annex; if it could, git-annex didn't contain such an encoding check before, so at worst that should be a wash.
25 lines
594 B
Haskell
25 lines
594 B
Haskell
{- git-annex transfer direction types
|
|
-
|
|
- Copyright 2012 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Types.Direction where
|
|
|
|
import qualified Data.ByteString as B
|
|
|
|
data Direction = Upload | Download
|
|
deriving (Eq, Ord, Show, Read)
|
|
|
|
formatDirection :: Direction -> B.ByteString
|
|
formatDirection Upload = "upload"
|
|
formatDirection Download = "download"
|
|
|
|
parseDirection :: B.ByteString -> Maybe Direction
|
|
parseDirection "upload" = Just Upload
|
|
parseDirection "download" = Just Download
|
|
parseDirection _ = Nothing
|
|
|