@@ -1,4 +1,4 @@
1−{-# LANGUAGE DeriveDataTypeable, CPP #-}
1+{-# LANGUAGE DeriveDataTypeable, CPP, TemplateHaskell #-}
22{-
33Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
44
@@ -504,12 +504,20 @@ inDirectory path action = do
504504 setCurrentDirectory oldDir
505505 return result
506506
507+#ifdef EMBED_DATA_FILES
508+dataFiles :: [(FilePath, B.ByteString)]
509+dataFiles = $(embedDir "data")
510+#endif
511+
507512readDefaultDataFile :: FilePath -> IO B.ByteString
508513readDefaultDataFile fname =
509514#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
511519#else
512− getDataFileName fname >>= B.readFile
520+ getDataFileName ("data" </> fname) >>= B.readFile
513521#endif
514522
515523-- | Read file from specified user data directory or, if not found there, from