+
+writeFileUsing :: String -> String -> IO ()
+writeFileUsing filename text = do
+ let dest_dir = reverse . dropWhile (\ x -> x /= '/') . reverse $ filename
+
+-- We need to check for the dest_dir each time, because we use sub-dirs for
+-- packages, and a single .tix file might contain information about
+-- many package.
+
+#if __GLASGOW_HASKELL__ >= 604
+ -- create the dest_dir if needed
+ when (not (null dest_dir)) $
+ createDirectoryIfMissing True dest_dir
+#endif
+
+ writeFile filename text
+
+------------------------------------------------------------------------------