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/main/filename-policy.sml
ViewVC logotype

Diff of /sml/trunk/src/cm/main/filename-policy.sml

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

revision 322, Tue Jun 8 09:36:16 1999 UTC revision 352, Wed Jun 23 09:27:27 1999 UTC
# Line 8  Line 8 
8  signature FILENAMEPOLICY = sig  signature FILENAMEPOLICY = sig
9    
10      type policy      type policy
11        type policyMaker = { arch: string, os: SMLofNJ.SysInfo.os_kind } -> policy
12    
13      val colocate :      val colocate : policyMaker
14          { arch: string, os: SMLofNJ.SysInfo.os_kind } -> policy      val separate : AbsPath.t -> policyMaker
     val separate :  
         { root: AbsPath.t, parentArc: string, absArc: string } -> policy  
15    
16      val mkBinPath : policy -> AbsPath.t -> AbsPath.t      val mkBinPath : policy -> AbsPath.t -> AbsPath.t
17      val mkSkelPath : policy -> AbsPath.t -> AbsPath.t      val mkSkelPath : policy -> AbsPath.t -> AbsPath.t
18      val mkStablePath : policy -> AbsPath.t -> AbsPath.t      val mkStablePath : policy -> AbsPath.t -> AbsPath.t
19  end  end
20    
21  structure FilenamePolicy :> FILENAMEPOLICY = struct  functor FilenamePolicyFn (val cmdir : string
22                              val skeldir : string) :> FILENAMEPOLICY = struct
23    
24      type converter = AbsPath.t -> AbsPath.t      type converter = AbsPath.t -> AbsPath.t
25    
26      type policy = { bin: converter, skel: converter, stable: converter }      type policy = { bin: converter, skel: converter, stable: converter }
27        type policyMaker = { arch: string, os: SMLofNJ.SysInfo.os_kind } -> policy
28    
29      fun kind2name SMLofNJ.SysInfo.BEOS = "beos"      fun kind2name SMLofNJ.SysInfo.BEOS = "beos"
30        | kind2name SMLofNJ.SysInfo.MACOS = "macos"        | kind2name SMLofNJ.SysInfo.MACOS = "macos"
# Line 31  Line 32 
32        | kind2name SMLofNJ.SysInfo.UNIX = "unix"        | kind2name SMLofNJ.SysInfo.UNIX = "unix"
33        | kind2name SMLofNJ.SysInfo.WIN32 = "win32"        | kind2name SMLofNJ.SysInfo.WIN32 = "win32"
34    
35        fun mkPolicy shift { arch, os } = let
36      fun cmpath d s = let      fun cmpath d s = let
37          val { dir = d0, file = f } = AbsPath.splitDirFile s          val { dir = d0, file = f } = AbsPath.splitDirFile s
38          val d1 = AbsPath.joinDirFile { dir = d0, file = "CM" }              val d1 = AbsPath.joinDirFile { dir = d0, file = cmdir }
39          val d2 = AbsPath.joinDirFile { dir = d1, file = d }          val d2 = AbsPath.joinDirFile { dir = d1, file = d }
40      in      in
41          AbsPath.joinDirFile { dir = d2, file = f }          AbsPath.joinDirFile { dir = d2, file = f }
42      end      end
   
     fun colocate { arch, os } = let  
43          val archos = concat [arch, "-", kind2name os]          val archos = concat [arch, "-", kind2name os]
44            val archosdep = cmpath archos o shift
45      in      in
46          { skel = cmpath "SKEL", bin = cmpath archos, stable = cmpath archos }          { skel = cmpath skeldir, bin = archosdep, stable = archosdep }
47      end      end
48    
49      fun separate { root, parentArc, absArc } = let      val colocate = mkPolicy (fn p => p)
50          val root = AbsPath.context root  
51          fun sep p = let      fun separate root = let
52              val s = AbsPath.name p          val root = AbsPath.relativeContext root
53              fun cvt arc = if arc = OS.Path.parentArc then parentArc else arc          fun shift p =
54          in              case AbsPath.reAnchor (p, root) of
55              case OS.Path.fromString s of                  SOME p' => p'
56                  { isAbs = false, vol = "", arcs } =>                | NONE => (Say.say ["Failure: ", AbsPath.name p,
57                      AbsPath.native { context = root,                                    " is not an anchored path!\n"];
58                                       spec = OS.Path.toString                           raise Fail "bad path")
                                          { isAbs = false, vol = "",  
                                            arcs = map cvt arcs } }  
               | _ => AbsPath.native  
                     { context = root,  
                       spec = OS.Path.joinDirFile { dir = absArc,  
                                                    file = AbsPath.file p } }  
         end  
59      in      in
60          { skel = cmpath "SKEL", bin = sep, stable = sep }          mkPolicy shift
61      end      end
62    
63      fun mkBinPath (p: policy) s = #bin p s      fun mkBinPath (p: policy) s = #bin p s
64      fun mkSkelPath (p: policy) s = #skel p s      fun mkSkelPath (p: policy) s = #skel p s
65      fun mkStablePath (p: policy) s = #stable p s      fun mkStablePath (p: policy) s = #stable p s
66  end  end
67    
68    structure FilenamePolicy =
69        FilenamePolicyFn (val cmdir = "NEWCM" val skeldir = "SKEL")

Legend:
Removed from v.322  
changed lines
  Added in v.352

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