12 |
* Author: Matthias Blume (blume@cs.princeton.edu) |
* Author: Matthias Blume (blume@cs.princeton.edu) |
13 |
*) |
*) |
14 |
signature SRCPATH = sig |
signature SRCPATH = sig |
15 |
|
|
16 |
|
exception Format (* if something is seriously wrong with a pickle *) |
17 |
|
exception BadAnchor of string (* if anchor cannot be resolved *) |
18 |
|
|
19 |
type context |
type context |
20 |
type t |
type t |
21 |
type ord_key = t |
type ord_key = t |
26 |
* the current state of the file system: *) |
* the current state of the file system: *) |
27 |
val sync : unit -> unit |
val sync : unit -> unit |
28 |
|
|
29 |
|
(* This makes sure CM knows what the current working directory is: *) |
30 |
|
val revalidateCwd : unit -> unit |
31 |
|
|
32 |
(* This erases all persistent state: *) |
(* This erases all persistent state: *) |
33 |
val clear : unit -> unit |
val clear : unit -> unit |
34 |
|
|
|
(* This should be called at the beginning of every main operation |
|
|
* to make sure CM knows what the current working directory is: *) |
|
|
val revalidateCwd : unit -> unit |
|
|
|
|
35 |
val osstring : t -> string |
val osstring : t -> string |
36 |
val descr : t -> string |
val descr : t -> string |
37 |
val reAnchoredName : t * string -> string option |
val reAnchoredName : t * string -> string option |
39 |
val specOf : t -> string |
val specOf : t -> string |
40 |
val contextName : context -> string |
val contextName : context -> string |
41 |
val sameDirContext : t -> context |
val sameDirContext : t -> context |
42 |
|
|
43 |
|
(* This will be called at the beginning of most main operations. |
44 |
|
* Therefore, it will automatically do the call to revalidateCwd. *) |
45 |
val cwdContext : unit -> context |
val cwdContext : unit -> context |
46 |
|
|
47 |
val native : { context: context, spec: string } -> t |
val native : { context: context, spec: string } -> t |
48 |
val standard : PathConfig.mode -> { context: context, spec: string } -> t |
val standard : PathConfig.mode -> { context: context, spec: string } -> t |
49 |
|
|
50 |
|
val fromDescr : PathConfig.mode -> string -> t |
51 |
|
|
52 |
val pickle : (bool -> unit) -> t * t -> string list |
val pickle : (bool -> unit) -> t * t -> string list |
53 |
val unpickle : PathConfig.mode -> string list * t -> t option |
val unpickle : PathConfig.mode -> string list * t -> t |
54 |
|
|
55 |
val tstamp : t -> TStamp.t |
val tstamp : t -> TStamp.t |
|
|
|
|
val openTextIn : t -> TextIO.instream |
|
56 |
end |
end |
57 |
|
|
58 |
structure SrcPath :> SRCPATH = struct |
structure SrcPath :> SRCPATH = struct |
59 |
|
|
60 |
|
exception Format = AbsPath.Format |
61 |
|
exception BadAnchor = AbsPath.BadAnchor |
62 |
|
|
63 |
type context = AbsPath.context |
type context = AbsPath.context |
64 |
type t = AbsPath.t * int |
type t = AbsPath.t * int |
65 |
type ord_key = t |
type ord_key = t |
71 |
|
|
72 |
fun sync () = |
fun sync () = |
73 |
(AbsPath.newEra (); |
(AbsPath.newEra (); |
74 |
knownPaths := foldl AbsPathMap.insert' AbsPathMap.empty |
knownPaths := |
75 |
(AbsPathMap.listItemsi (!knownPaths))) |
AbsPathMap.foldli (fn (k, v, m) => AbsPathMap.insert (m, k, v)) |
76 |
|
AbsPathMap.empty |
77 |
|
(!knownPaths)) |
78 |
|
|
79 |
fun clear () = knownPaths := AbsPathMap.empty |
fun clear () = knownPaths := AbsPathMap.empty |
80 |
|
|
93 |
|
|
94 |
val native = intern o AbsPath.native |
val native = intern o AbsPath.native |
95 |
fun standard m = intern o AbsPath.standard m |
fun standard m = intern o AbsPath.standard m |
96 |
|
fun fromDescr m = intern o AbsPath.fromDescr m |
97 |
|
|
98 |
val contextName = AbsPath.contextName |
val contextName = AbsPath.contextName |
99 |
fun contextOf (ap, _) = AbsPath.contextOf ap |
fun contextOf (ap, _) = AbsPath.contextOf ap |
105 |
fun sameDirContext (ap, _) = AbsPath.sameDirContext ap |
fun sameDirContext (ap, _) = AbsPath.sameDirContext ap |
106 |
val cwdContext = AbsPath.cwdContext |
val cwdContext = AbsPath.cwdContext |
107 |
|
|
|
fun openTextIn (ap, _) = AbsPath.openTextIn ap |
|
|
|
|
108 |
fun pickle warn ((ap, _), (cap, _)) = AbsPath.pickle warn (ap, cap) |
fun pickle warn ((ap, _), (cap, _)) = AbsPath.pickle warn (ap, cap) |
109 |
fun unpickle m (l, (cap, _)) = |
fun unpickle m (l, (cap, _)) = intern (AbsPath.unpickle m (l, cap)) |
|
Option.map intern (AbsPath.unpickle m (l, cap)) |
|
110 |
end |
end |