M3Extension
provides operations on filename extensions.
INTERFACEThere are a number of extensions commonly used by an M3 system, captured by the enumeration typeM3Extension ; TYPE T = {Int, (* interface source *) IntG, (* generic interface source *) PInt, (* pickled interface (AST) *) PIntR, (* pickled interface, reduced AST *) Mod, (* module source *) ModG, (* generic module source *) PMod, (* pickled module (AST) *) PModR, (* pickled module, reduced AST *) IObj, (* (interface) object *) MObj, (* (module) object *) Exe, (* executable *) IC, (* (interface) C intermediate *) MC, (* (module) C intermediate *) IAsm, (* (interface) assembly code *) MAsm, (* (module) assembly code *) IX, (* (interface) pre-linker input *) MX, (* (module) pre-linker input *) ObjLib, (* object library *) ObjLibX, (* pre-linker input library *) Tmp, (* temporary file *) Null}; (* no extension *) TSet = SET OF T;
T
. Not all the extension types may be utilised
by a given implementation. The actual characters used to denote a T
may vary between implementations.
CONST Ints = TSet{T.Int, T.IntG}; Mods = TSet{T.Mod, T.ModG}; All = TSet{FIRST(T)..LAST(T)}; PROCEDURE ToText(t: T): TEXT;
Returns theTEXT
corresponding tot
PROCEDURE FromText(text: TEXT; VAR t: T): BOOLEAN;
Iftext
is a valid Modula-3 extension, sett
and returnTRUE
. Otherwise, leavet
unchanged and returnFALSE
.
PROCEDURE Extend(name: TEXT; t: T): TEXT;
Ift = T.Null
, then returnPathname.Base(name)
else returnPathname.Join(NIL, Pathname.Base(name), ToText(t))
.
PROCEDURE Has(name: TEXT; VAR t: T): BOOLEAN;
Returns FromText(Pathname.LastExt(name), t)
.
END M3Extension.