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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/cm/main/filename-policy.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 375 - (view) (download)

1 : blume 297 (*
2 :     * A type representing different choices for file naming conventions.
3 :     *
4 :     * (C) 1999 Lucent Technologies, Bell Laboratories
5 :     *
6 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
7 :     *)
8 :     signature FILENAMEPOLICY = sig
9 :    
10 :     type policy
11 : blume 329 type policyMaker = { arch: string, os: SMLofNJ.SysInfo.os_kind } -> policy
12 : blume 297
13 : blume 329 val colocate : policyMaker
14 : blume 357 val separate : { bindir: string, bootdir: string } -> policyMaker
15 : blume 297
16 : blume 354 val mkBinName : policy -> SrcPath.t -> string
17 :     val mkSkelName : policy -> SrcPath.t -> string
18 :     val mkStableName : policy -> SrcPath.t -> string
19 : blume 357
20 :     val kind2name : SMLofNJ.SysInfo.os_kind -> string
21 : blume 297 end
22 :    
23 : blume 331 functor FilenamePolicyFn (val cmdir : string
24 :     val skeldir : string) :> FILENAMEPOLICY = struct
25 : blume 297
26 : blume 354 type converter = SrcPath.t -> string
27 : blume 297
28 : blume 322 type policy = { bin: converter, skel: converter, stable: converter }
29 : blume 329 type policyMaker = { arch: string, os: SMLofNJ.SysInfo.os_kind } -> policy
30 : blume 297
31 : blume 322 fun kind2name SMLofNJ.SysInfo.BEOS = "beos"
32 :     | kind2name SMLofNJ.SysInfo.MACOS = "macos"
33 :     | kind2name SMLofNJ.SysInfo.OS2 = "os2"
34 :     | kind2name SMLofNJ.SysInfo.UNIX = "unix"
35 :     | kind2name SMLofNJ.SysInfo.WIN32 = "win32"
36 :    
37 : blume 357 fun mkPolicy (shiftbin, shiftstable) { arch, os } = let
38 : blume 354 fun cmname d s = let
39 :     val { dir = d0, file = f } = OS.Path.splitDirFile s
40 :     val d1 = OS.Path.joinDirFile { dir = d0, file = cmdir }
41 :     val d2 = OS.Path.joinDirFile { dir = d1, file = d }
42 : blume 329 in
43 : blume 354 OS.Path.joinDirFile { dir = d2, file = f }
44 : blume 329 end
45 : blume 322 val archos = concat [arch, "-", kind2name os]
46 :     in
47 : blume 357 { skel = cmname skeldir o SrcPath.osstring,
48 :     bin = cmname archos o shiftbin,
49 :     stable = cmname archos o shiftstable }
50 : blume 322 end
51 :    
52 : blume 357 val colocate = mkPolicy (SrcPath.osstring, SrcPath.osstring)
53 : blume 329
54 : blume 357 fun separate { bindir, bootdir } = let
55 :     fun shiftname root p =
56 : blume 354 case SrcPath.reAnchoredName (p, root) of
57 :     SOME s => s
58 :     | NONE => (Say.say ["Failure: ", SrcPath.descr p,
59 : blume 352 " is not an anchored path!\n"];
60 :     raise Fail "bad path")
61 : blume 322 in
62 : blume 357 mkPolicy (shiftname bindir, shiftname bootdir)
63 : blume 322 end
64 :    
65 : blume 354 fun mkBinName (p: policy) s = #bin p s
66 :     fun mkSkelName (p: policy) s = #skel p s
67 :     fun mkStableName (p: policy) s = #stable p s
68 : blume 297 end
69 : blume 331
70 :     structure FilenamePolicy =
71 : blume 375 FilenamePolicyFn (val cmdir = "CM" val skeldir = "SKEL")

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