Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
Paths


NAME

Paths - resolving string constants into name paths

SYNOPSIS

CONST separator = "/";
TYPE Path = POINTER TO PathRec;
TYPE PathRec =
   RECORD
      (Objects.ObjectRec)
      component: Names.Name;
      next: Path;
   END;
TYPE ErrorCode = SHORTINT;
TYPE ErrorEvent = POINTER TO ErrorEventRec;
TYPE ErrorEventRec =
   RECORD
      (Events.EventRec)
      errorcode: ErrorCode;
   END;
VAR errormsg: ARRAY errorcodes OF Events.Message;
VAR error: Events.EventType;


PROCEDURE Convert(path: ARRAY OF CHAR): Path; PROCEDURE GetNode(path: ARRAY OF CHAR; auth: Shards.Lid; errors: RelatedEvents.Object; VAR subnode: Names.Node): BOOLEAN; PROCEDURE GetNodeN(node: Names.Node; path: ARRAY OF CHAR; auth: Shards.Lid; errors: RelatedEvents.Object; VAR subnode: Names.Node): BOOLEAN; PROCEDURE Insert(path: ARRAY OF CHAR; subnode: Names.Node; auth: Shards.Lid; errors: RelatedEvents.Object): BOOLEAN; PROCEDURE InsertN(node: Names.Node; path: ARRAY OF CHAR; subnode: Names.Node; auth: Shards.Lid; errors: RelatedEvents.Object): BOOLEAN; PROCEDURE Delete(path: ARRAY OF CHAR; auth: Shards.Lid; errors: RelatedEvents.Object): BOOLEAN; PROCEDURE DeleteN(node: Names.Node; path: ARRAY OF CHAR; auth: Shards.Lid; errors: RelatedEvents.Object): BOOLEAN;

DESCRIPTION

Paths provides an interface to Names resolving string constants into name paths. For each procedure in Names with an argument of type Names.Node and another one of type Names.Name there are two equivalent procedures in Paths with either an absolute or a relative path instead. In all cases path is a 0X-terminated array of characters containing path components. Within path, two consecutive separator characters are replaced by a single one, whereas a single separator character is replaced by nothing, separating path components.

Paths are evaluated from left to right as a sequence of Names.GetNode calls until exactly one component remains unresolved, which becomes the name argument to the requested procedure.

Convert simply converts a string to a Path structure.

EXAMPLE

success := Paths.Insert("etc/example", subnode, auth, errors)
is essentially equivalent to:
ConstStrings.Create(etcString, "etc");
ConstStrings.Create(exampleString, "example");
success :=
   Names.GetNode(Names.root, etcString, auth, tmpnode) &
   Names.Insert(tmpnode, subnode, exampleString, auth)
except for the redirection of error events.

DIAGNOSTICS

All procedures return TRUE on success, otherwise FALSE. Error events, usually raised in the context of Names procedures, are forwarded to errors. If not stated otherwise, their priority is Priorities.liberrors. In case of an inappropriate path argument an error event of type ErrorEvent is related to errors with following error code and message:
zeroPathLen
insert/delete need a nonempty path

SEE ALSO

Names
abstraction for name hierarchies
ConstStrings
handling of arbitrarily long strings
Services
type-independent definition of extensions
RelatedEvents
error event handling

AUTHOR

Martin Hasch, University of Ulm
Edited by: martin, last change: 1996/07/22, revision: 1.2, converted to HTML: 1997/04/28

Oberon || Library || Module Index || Search Engine || Definition || Module