Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/cm/smlfile/skel-io.sml
ViewVC logotype

Diff of /sml/trunk/src/cm/smlfile/skel-io.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 340, Fri Jun 18 05:32:46 1999 UTC revision 345, Sun Jun 20 11:55:26 1999 UTC
# Line 7  Line 7 
7   *)   *)
8  signature SKELIO = sig  signature SKELIO = sig
9      val read : AbsPath.t * TStamp.t -> Skeleton.decl option      val read : AbsPath.t * TStamp.t -> Skeleton.decl option
10      val write : AbsPath.t * Skeleton.decl -> unit      val write : AbsPath.t * Skeleton.decl * TStamp.t -> unit
11  end  end
12    
13  structure SkelIO :> SKELIO = struct  structure SkelIO :> SKELIO = struct
# Line 130  Line 130 
130      end      end
131    
132      fun read (ap, ts) =      fun read (ap, ts) =
133          if TStamp.earlier (AbsPath.tstamp ap, ts) then NONE          if TStamp.needsUpdate { target = AbsPath.tstamp ap, source = ts } then
134          else let              NONE
135              val s = AbsPath.openBinIn ap          else
136              val r = read_decl s              SOME (SafeIO.perform { openIt = fn () => AbsPath.openBinIn ap,
137                  handle exn => (BinIO.closeIn s; raise exn)                                     closeIt = BinIO.closeIn,
138          in                                     work = read_decl,
139              BinIO.closeIn s; SOME r                                     cleanup = fn () => () })
140          end handle _ => NONE              handle _ => NONE
141    
142      fun write (ap, sk) = let      fun write (ap, sk, ts) = let
143          val s = AbsPath.openBinOut ap          fun cleanup () = let
     in  
         (Interrupt.guarded (fn () => write_decl (s, sk));  
          BinIO.closeOut s)  
         handle exn => let  
144              val p = AbsPath.name ap              val p = AbsPath.name ap
145          in          in
             BinIO.closeOut s;  
146              OS.FileSys.remove p handle _ => ();              OS.FileSys.remove p handle _ => ();
147              Say.say ["[writing ", p, " failed]\n"];              Say.say ["[writing ", p, " failed]\n"]
148              raise exn          end
149        in
150            SafeIO.perform { openIt = fn () => AbsPath.openBinOut ap,
151                             closeIt = BinIO.closeOut,
152                             work = fn s => write_decl (s, sk),
153                             cleanup = cleanup };
154            AbsPath.setTime (ap, ts)
155          end          end
     end handle Interrupt.Interrupt => raise Interrupt.Interrupt  
              | _ => ()  
156  end  end

Legend:
Removed from v.340  
changed lines
  Added in v.345

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0