module Codec.Archive.Tar.PackAscii
  ( packAscii
  ) where

import qualified Data.ByteString.Char8 as BS.Char8
import Data.Char
import GHC.Stack

-- | We should really migrate to @OsPath@ from @filepath@ package,
-- but for now let's not corrupt data silently.
packAscii :: HasCallStack => FilePath -> BS.Char8.ByteString
packAscii :: HasCallStack => FilePath -> ByteString
packAscii FilePath
xs
  | forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Char -> Bool
isAscii FilePath
xs = FilePath -> ByteString
BS.Char8.pack FilePath
xs
  | Bool
otherwise = forall a. HasCallStack => FilePath -> a
error forall a b. (a -> b) -> a -> b
$ FilePath
"packAscii: only ASCII filenames are supported, but got " forall a. [a] -> [a] -> [a]
++ FilePath
xs