summaryrefslogtreecommitdiff
path: root/src/editor/simple/save.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2011-06-08 15:29:50 +0000
committerhallgren <hallgren@chalmers.se>2011-06-08 15:29:50 +0000
commit25ae9b2dc4d2a2a5bd2e1920e1ee82dfbef4162e (patch)
treedda562ccde336a8a624a19f7aae42a4f4705f30e /src/editor/simple/save.hs
parent25a9efb13c05bc806dff8d23c6be97013aa981ea (diff)
gfse: initial support for grammars in the cloud
This lets the user access the same set of grammars from multiple devices. Sharing grammars between multiple users is possible but discouraged at the moment. There is no version handling, so concurrent editing of the same grammar by different users might result in one user overwriting changes made by another user. (The same goes for cuncurrent editing on multiple devices by a single user, of course.)
Diffstat (limited to 'src/editor/simple/save.hs')
-rw-r--r--src/editor/simple/save.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/editor/simple/save.hs b/src/editor/simple/save.hs
index 01d3ce270..e29287d33 100644
--- a/src/editor/simple/save.hs
+++ b/src/editor/simple/save.hs
@@ -1,12 +1,17 @@
-import Monad(zipWithM_)
+import Monad(zipWithM)
import System(getArgs)
main = save =<< getArgs
save [dir] =
do fs@[ns,_] <- readIO =<< getContents
- save_all fs
- putStrLn $ unwords [n++".gf"|n<-ns]
+ nes <- save_all fs
+ putStrLn $ unwords nes
where
- save_all [ns,cs] = zipWithM_ write1 ns cs
- write1 n = writeFile (dir++"/"++n++".gf")
+ save_all [ns,cs] = zipWithM write1 ns cs
+ write1 n c =
+ do writeFile (dir++"/"++ne) c
+ return ne
+ where
+ ne=if '.' `elem` n then n else n++".gf"
+ \ No newline at end of file