@@ -15,9 +15,10 @@ import System.FilePath.Posix ((</>))
1515
1616import Obelisk.ExecutableConfig.Internal.AssetManager
1717
18−getFromMgr mgr withCS name = do
18+getFromMgr :: AAssetManager -> BS.ByteString -> IO (Maybe Text)
19+getFromMgr mgr name = do
1920 let open = do
20− a <- withCS name $ \fn ->
21+ a <- BS.useAsCString name $ \fn ->
2122 assetManager_open mgr fn 3
2223 return $ if unAAsset a == nullPtr
2324 then Nothing
@@ -29,14 +30,7 @@ getFromMgr mgr withCS name = do
2930 fmap T.decodeUtf8 $ BS.packCStringLen (b, fromIntegral l)
3031
3132getFrontendConfigs :: IO [(Text, Text)]
32−getFrontendConfigs
33− = fmap (sortOn fst)
34− $ getConfigs
35− $ \fp -> BS.isPrefixOf (BS.pack $ fmap (fromIntegral . fromEnum) "config/common/") fp
36− || BS.isPrefixOf (BS.pack $ fmap (fromIntegral . fromEnum) "config/frontend/") fp
37−
38−getConfigs :: (BS.ByteString -> Bool) -> IO [(Text, Text)]
39−getConfigs p = bracket getAssets freeAssetManager $ \mgrObj -> do
33+getFrontendConfigs = bracket getAssets freeAssetManager $ \mgrObj -> do
4034 mgr <- assetManagerFromJava mgrObj
4135 let openDir = do
4236 d <- withCString "config.files" $ \fn ->
@@ -51,12 +45,12 @@ getConfigs p = bracket getAssets freeAssetManager $ \mgrObj -> do
5145 l <- asset_getLength asset
5246 lines0 <$> BS.packCStringLen (b, fromIntegral l)
5347 Nothing -> error "could not open configuration manifest 'config.files'"
54− fmap catMaybes $ forM (filter p configPaths) $ \fp ->
55− fmap (\v -> (T.decodeUtf8 fp,v)) <$> getFromMgr mgr BS.useAsCString fp
48+ fmap catMaybes $ forM configPaths $ \fp ->
49+ fmap (\v -> (T.decodeUtf8 fp,v)) <$> getFromMgr mgr fp
5650
5751lines0 :: BS.ByteString -> [BS.ByteString]
5852lines0 ps
59− | BS.null ps = []
60− | otherwise = case BS.elemIndex 0 ps of
61− Nothing -> [ps]
62− Just n -> BS.take n ps : lines0 (BS.drop (n+1) ps)
53+ | BS.null ps = []
54+ | otherwise = case BS.elemIndex 0 ps of
55+ Nothing -> [ps]
56+ Just n -> BS.take n ps : lines0 (BS.drop (n+1) ps)