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/paths/srcpath.sml
ViewVC logotype

Annotation of /sml/trunk/src/cm/paths/srcpath.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 464 - (view) (download)

1 : blume 354 (*
2 :     * Operations over abstract path names.
3 :     * This is the "surface" abstraction that the client actually gets to
4 :     * see. It is built on top of the "AbsPath" abstraction, but its
5 :     * important improvement over AbsPath is that the ordering relation
6 :     * is stable: once you have created two "SrcPath"s, they will always
7 :     * compare the same way -- even if files are moved about, file_ids
8 :     * change, etc.
9 :     *
10 :     * Copyright (c) 1999 by Lucent Technologies, Bell Laboratories
11 :     *
12 :     * Author: Matthias Blume (blume@cs.princeton.edu)
13 :     *)
14 :     signature SRCPATH = sig
15 : blume 367
16 :     exception Format (* if something is seriously wrong with a pickle *)
17 :     exception BadAnchor of string (* if anchor cannot be resolved *)
18 :    
19 : blume 354 type context
20 :     type t
21 :     type ord_key = t
22 :    
23 :     val compare : ord_key * ord_key -> order
24 :    
25 :     (* This rebuilds the internal table in a manner consistent with
26 :     * the current state of the file system: *)
27 :     val sync : unit -> unit
28 :    
29 : blume 366 (* This makes sure CM knows what the current working directory is: *)
30 :     val revalidateCwd : unit -> unit
31 :    
32 : blume 464 (* This marks the cwd cache as invalid so that the next revalidation
33 :     * will cause external servers to be notified. *)
34 :     val invalidateCwd : unit -> unit
35 :    
36 : blume 354 (* This erases all persistent state: *)
37 :     val clear : unit -> unit
38 :    
39 :     val osstring : t -> string
40 :     val descr : t -> string
41 :     val reAnchoredName : t * string -> string option
42 :     val contextOf : t -> context
43 :     val specOf : t -> string
44 :     val contextName : context -> string
45 :     val sameDirContext : t -> context
46 : blume 366
47 :     (* This will be called at the beginning of most main operations.
48 :     * Therefore, it will automatically do the call to revalidateCwd. *)
49 : blume 354 val cwdContext : unit -> context
50 :    
51 :     val native : { context: context, spec: string } -> t
52 :     val standard : PathConfig.mode -> { context: context, spec: string } -> t
53 :    
54 : blume 457 val fromDescr : PathConfig.mode -> string -> t
55 :    
56 : blume 354 val pickle : (bool -> unit) -> t * t -> string list
57 : blume 367 val unpickle : PathConfig.mode -> string list * t -> t
58 : blume 354
59 :     val tstamp : t -> TStamp.t
60 :     end
61 :    
62 :     structure SrcPath :> SRCPATH = struct
63 :    
64 : blume 367 exception Format = AbsPath.Format
65 :     exception BadAnchor = AbsPath.BadAnchor
66 :    
67 : blume 354 type context = AbsPath.context
68 :     type t = AbsPath.t * int
69 :     type ord_key = t
70 :    
71 :     fun compare ((_, i), (_, i')) = Int.compare (i, i')
72 :    
73 :     val knownPaths = ref (AbsPathMap.empty: int AbsPathMap.map)
74 :     val nextId = ref 0
75 :    
76 :     fun sync () =
77 :     (AbsPath.newEra ();
78 : blume 377 knownPaths :=
79 :     AbsPathMap.foldli (fn (k, v, m) => AbsPathMap.insert (m, k, v))
80 :     AbsPathMap.empty
81 :     (!knownPaths))
82 : blume 354
83 :     fun clear () = knownPaths := AbsPathMap.empty
84 :    
85 :     val revalidateCwd = AbsPath.revalidateCwd
86 : blume 464 val invalidateCwd = AbsPath.invalidateCwd
87 : blume 354
88 :     fun intern ap =
89 :     case AbsPathMap.find (!knownPaths, ap) of
90 :     SOME i => (ap, i)
91 :     | NONE => let
92 :     val i = !nextId
93 :     in
94 :     nextId := i + 1;
95 :     knownPaths := AbsPathMap.insert (!knownPaths, ap, i);
96 :     (ap, i)
97 :     end
98 :    
99 :     val native = intern o AbsPath.native
100 :     fun standard m = intern o AbsPath.standard m
101 : blume 457 fun fromDescr m = intern o AbsPath.fromDescr m
102 : blume 354
103 :     val contextName = AbsPath.contextName
104 :     fun contextOf (ap, _) = AbsPath.contextOf ap
105 :     fun specOf (ap, _) = AbsPath.specOf ap
106 :     fun osstring (ap, _) = AbsPath.osstring ap
107 :     fun descr (ap, _) = AbsPath.descr ap
108 :     fun reAnchoredName ((ap, _), root) = AbsPath.reAnchoredName (ap, root)
109 :     fun tstamp (ap, _) = AbsPath.tstamp ap
110 :     fun sameDirContext (ap, _) = AbsPath.sameDirContext ap
111 :     val cwdContext = AbsPath.cwdContext
112 :    
113 :     fun pickle warn ((ap, _), (cap, _)) = AbsPath.pickle warn (ap, cap)
114 : blume 367 fun unpickle m (l, (cap, _)) = intern (AbsPath.unpickle m (l, cap))
115 : blume 354 end

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