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 492 - (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 : blume 492 (* like osstring; return relative path if shorter *)
41 :     val osstring' : t -> string
42 : blume 354 val descr : t -> string
43 :     val reAnchoredName : t * string -> string option
44 :     val contextOf : t -> context
45 :     val specOf : t -> string
46 :     val contextName : context -> string
47 :     val sameDirContext : t -> context
48 : blume 366
49 :     (* This will be called at the beginning of most main operations.
50 :     * Therefore, it will automatically do the call to revalidateCwd. *)
51 : blume 354 val cwdContext : unit -> context
52 :    
53 :     val native : { context: context, spec: string } -> t
54 :     val standard : PathConfig.mode -> { context: context, spec: string } -> t
55 :    
56 : blume 457 val fromDescr : PathConfig.mode -> string -> t
57 :    
58 : blume 354 val pickle : (bool -> unit) -> t * t -> string list
59 : blume 367 val unpickle : PathConfig.mode -> string list * t -> t
60 : blume 354
61 :     val tstamp : t -> TStamp.t
62 :     end
63 :    
64 :     structure SrcPath :> SRCPATH = struct
65 :    
66 : blume 367 exception Format = AbsPath.Format
67 :     exception BadAnchor = AbsPath.BadAnchor
68 :    
69 : blume 354 type context = AbsPath.context
70 :     type t = AbsPath.t * int
71 :     type ord_key = t
72 :    
73 :     fun compare ((_, i), (_, i')) = Int.compare (i, i')
74 :    
75 :     val knownPaths = ref (AbsPathMap.empty: int AbsPathMap.map)
76 :     val nextId = ref 0
77 :    
78 :     fun sync () =
79 :     (AbsPath.newEra ();
80 : blume 377 knownPaths :=
81 :     AbsPathMap.foldli (fn (k, v, m) => AbsPathMap.insert (m, k, v))
82 :     AbsPathMap.empty
83 :     (!knownPaths))
84 : blume 354
85 :     fun clear () = knownPaths := AbsPathMap.empty
86 :    
87 :     val revalidateCwd = AbsPath.revalidateCwd
88 : blume 464 val invalidateCwd = AbsPath.invalidateCwd
89 : blume 354
90 :     fun intern ap =
91 :     case AbsPathMap.find (!knownPaths, ap) of
92 :     SOME i => (ap, i)
93 :     | NONE => let
94 :     val i = !nextId
95 :     in
96 :     nextId := i + 1;
97 :     knownPaths := AbsPathMap.insert (!knownPaths, ap, i);
98 :     (ap, i)
99 :     end
100 :    
101 :     val native = intern o AbsPath.native
102 :     fun standard m = intern o AbsPath.standard m
103 : blume 457 fun fromDescr m = intern o AbsPath.fromDescr m
104 : blume 354
105 :     val contextName = AbsPath.contextName
106 :     fun contextOf (ap, _) = AbsPath.contextOf ap
107 :     fun specOf (ap, _) = AbsPath.specOf ap
108 :     fun osstring (ap, _) = AbsPath.osstring ap
109 : blume 492 fun osstring' (ap, _) = AbsPath.osstring' ap
110 : blume 354 fun descr (ap, _) = AbsPath.descr ap
111 :     fun reAnchoredName ((ap, _), root) = AbsPath.reAnchoredName (ap, root)
112 :     fun tstamp (ap, _) = AbsPath.tstamp ap
113 :     fun sameDirContext (ap, _) = AbsPath.sameDirContext ap
114 :     val cwdContext = AbsPath.cwdContext
115 :    
116 :     fun pickle warn ((ap, _), (cap, _)) = AbsPath.pickle warn (ap, cap)
117 : blume 367 fun unpickle m (l, (cap, _)) = intern (AbsPath.unpickle m (l, cap))
118 : blume 354 end

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