@@ -1,4 +1,4 @@
1−{-# LANGUAGE DeriveDataTypeable, CPP #-}
1+{-# LANGUAGE DeriveDataTypeable, CPP, TemplateHaskell #-}
3Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
3Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
@@ -504,12 +504,20 @@ inDirectory path action = do
504 setCurrentDirectory oldDir
504 setCurrentDirectory oldDir
505 return result
505 return result
507+#ifdef EMBED_DATA_FILES
508+dataFiles :: [(FilePath, B.ByteString)]
509+dataFiles = $(embedDir "data")
507readDefaultDataFile :: FilePath -> IO B.ByteString
512readDefaultDataFile :: FilePath -> IO B.ByteString
508readDefaultDataFile fname =
513readDefaultDataFile fname =
509#ifdef EMBED_DATA_FILES
514#ifdef EMBED_DATA_FILES
510− TODO
515+ case lookup fname dataFiles of
516+ Nothing -> ioError $ userError
517+ $ "Data file `" ++ fname ++ "' does not exist"
518+ Just contents -> return contents
512− getDataFileName fname >>= B.readFile
520+ getDataFileName ("data" </> fname) >>= B.readFile
515-- | Read file from specified user data directory or, if not found there, from
523-- | Read file from specified user data directory or, if not found there, from