module MyIO where -- import Codec.Utils (Octet) import Data.Word import System.Time import System.IO import System.Locale import qualified Data.ByteString as B writeOctet :: [Word8] -> String -> String -> IO String writeOctet bmp dir ext = do time <- getClockTime ctime <- toCalendarTime time let p0 = ctPicosec ctime let (s1, p1) = p0 `divMod` (10 ^ 11) let (s2, p2) = p1 `divMod` (10 ^ 10) let (s3, _) = p2 `divMod` (10 ^ 9) let filePath = formatCalendarTime (defaultTimeLocale) (dir ++ "tmp%Y%m%d%H%M%S" ++ show s1 ++ show s2 ++ show s3 ++ ext) ctime h <- openFile filePath WriteMode B.hPut h (B.pack bmp) hClose h return filePath