1 files changed, 14 insertions(+), 1 deletions(-)
M src/Links.hs
M src/Links.hs => src/Links.hs +14 -1
@@ 136,7 136,20 @@ readBookmarks = do
dir <- getXdgDirectory XdgData "rhapsode"
let file = dir </> "links.xml"
exists <- doesFileExist file
- if exists then Text.XML.readFile def file `catch` handleInvalid else nodoc
+
+ if exists then return () else do
+ -- Copy defaults into userdir
+ dirs <- getXdgDirectoryList XdgDataDirs
+ files' <- forM dirs $ \dir' -> do
+ let file' = dir' </> "rhapsode" </> "links.xml"
+ exists' <- doesFileExist file'
+ return $ if exists' then Just file' else Nothing
+ case catMaybes files' of
+ [] -> return ()
+ (file':_) -> copyFileWithMetadata file' file
+
+ exists' <- doesFileExist file
+ if exists' then Text.XML.readFile def file `catch` handleInvalid else nodoc
where
handleInvalid err@(InvalidXMLFile _ _) = hPrint stderr err >> nodoc
nodoc = return $ Document (Prologue [] Nothing []) (Element "empty" M.empty []) []