module System.FileSystem.Instances
(
) where
import Data.Monoid (Monoid (..))
import Control.Arrow (second)
import Data.Binary (Binary (..) , Word8 , Get)
import System.Time (ClockTime (..))
import System.FileSystem.Types
import System.FileSystem.Operators
instance Monoid FileSystem where
mempty = emptyFileSystem
mappend = curry $ uncurry (foldr (<<:)) . second dirCnt
instance Binary ClockTime where
put (TOD s m) = do put (0 :: Word8)
put s
put m
get = do t <- get :: Get Word8
case t of
0 -> do s <- get
m <- get
return (TOD s m)
instance Binary FileData where
put (FD cnt lmt) = do put (0 :: Word8)
put cnt
put lmt
get = do t <- get :: Get Word8
case t of
0 -> do cnt <- get
lmt <- get
return (FD cnt lmt)
instance Binary File where
put (File fd fn) = do put (0 :: Word8)
put fd
put fn
get = do t <- get :: Get Word8
case t of
0 -> do fd <- get
fn <- get
return (File fd fn)
instance Binary FileSystem where
put (Directory xs) = do put (0 :: Word8)
put xs
get = do t <- get :: Get Word8
case t of
0 -> do xs <- get
return (Directory xs)