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/util/autodir.sml
ViewVC logotype

Diff of /sml/trunk/src/cm/util/autodir.sml

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

revision 376, Wed Jul 7 04:25:11 1999 UTC revision 452, Mon Oct 25 08:33:25 1999 UTC
# Line 17  Line 17 
17      fun fileExists n = F.access (n, []) handle _ => false      fun fileExists n = F.access (n, []) handle _ => false
18    
19      fun openOut fileopener p = let      fun openOut fileopener p = let
20          fun mkDir d = if fileExists d then () else F.mkDir d          fun mkDir d =
21                F.mkDir d handle exn => (if fileExists d then () else raise exn)
22          fun generic (maker, pmaker, p) =          fun generic (maker, pmaker, p) =
23              maker p              maker p
24              handle exn => let              handle exn => let
25                  val dir = P.dir p                  val dir = P.dir p
26              in              in
27                  if dir = "" orelse fileExists dir then raise exn                  (* If the parent dir exists, then we must consider
28                     * these cases:
29                     *   - non-parallel: we should signal an error
30                     *   - parallel: somebody else may have made this dir
31                     *      in the meantime, so we should try again
32                     * Both cases can be handled by simply calling maker
33                     * again.  (It will fail in the non-parallel case, but
34                     * that's actually what we want.) *)
35                    if dir = "" orelse fileExists dir then maker p
36                  else (pmaker dir; maker p)                  else (pmaker dir; maker p)
37              end              end
38          fun makedirs dir = generic (mkDir, makedirs, dir)          fun makedirs dir = generic (mkDir, makedirs, dir)

Legend:
Removed from v.376  
changed lines
  Added in v.452

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