From 877cb21d1630d32c6e40eb7c6f0ecc7e1da2bd52 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 18 Nov 2012 21:56:52 +0100 Subject: Add Item abstraction --- src/Hakyll/Core/Writable/CopyFile.hs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/Hakyll/Core/Writable') diff --git a/src/Hakyll/Core/Writable/CopyFile.hs b/src/Hakyll/Core/Writable/CopyFile.hs index 2d92891..58397ac 100644 --- a/src/Hakyll/Core/Writable/CopyFile.hs +++ b/src/Hakyll/Core/Writable/CopyFile.hs @@ -9,8 +9,7 @@ module Hakyll.Core.Writable.CopyFile -------------------------------------------------------------------------------- -import Control.Applicative ((<$>)) -import Data.Binary (Binary) +import Data.Binary (Binary (..)) import Data.Typeable (Typeable) import System.Directory (copyFile) @@ -18,20 +17,27 @@ import System.Directory (copyFile) -------------------------------------------------------------------------------- import Hakyll.Core.Compiler import Hakyll.Core.Identifier +import Hakyll.Core.Item import Hakyll.Core.Writable -------------------------------------------------------------------------------- --- | Newtype construct around 'FilePath' which will copy the file directly -newtype CopyFile = CopyFile {unCopyFile :: FilePath} - deriving (Show, Eq, Ord, Binary, Typeable) +-- | This will copy any file directly by using a system call +data CopyFile = CopyFile + deriving (Show, Eq, Ord, Typeable) + + +-------------------------------------------------------------------------------- +instance Binary CopyFile where + put CopyFile = return () + get = return CopyFile -------------------------------------------------------------------------------- instance Writable CopyFile where - write dst (CopyFile src) = copyFile src dst + write dst item = copyFile (toFilePath $ itemIdentifier item) dst -------------------------------------------------------------------------------- -copyFileCompiler :: Compiler CopyFile -copyFileCompiler = CopyFile . toFilePath <$> getIdentifier +copyFileCompiler :: Compiler (Item CopyFile) +copyFileCompiler = makeItem CopyFile -- cgit v1.2.3