ORIGIN '~beta/basiclib/file'; LIB_DEF 'unixfile' '../lib'; BODY 'private/unixfile_body'; ---- LIB: attributes ---- UnixEntry: DiskEntry (* Pattern describing unix specific attributes of disk-entries like * files and directories in a hierarchic unix file system *) (# <<SLOT UnixEntryLib: attributes>>; UnixEntryExisted: Exception (* Raised on attempt to make an existing unix entry into a * symbolic link using linkTo or linkFrom. Message: "Attempt to * make an existing UnixEntry into a symbolic link" *) (# ... #); followlinks: (* If the disk entry corresponding to THIS(UnixEntry).path * exists and is a link to some other entry, then if * followlinks is true the disk entry pointed to is manipulated * by the operations below, otherwise the link itself is * manipulated. Defaults to TRUE. *) (# f: @boolean; enter (# enter f ... #) exit (# ... exit f #) #); permission: @permissiondesc (* An object to manipulate the protection and mode of * THIS(UnixEntry). This gives a more fine-grained access to * the unix permissions than the inherited attributes * "readable" and "writeable". All operations on "permission" * are used like this : * * (who,mode) -> permission.operation ... ; * * "who" denotes a category of users : 'a' -- all, 'u' -- user * (owner), 'g' -- group, 'o' -- other. * * "mode" denotes the mode of THIS(UnixEntry) : 'r' -- read, * 'w' -- write, 'x' -- execute. *); permissiondesc:<(# <<SLOT UnixFilePermLib: attributes>>; (* PERMISSION EXCEPTIONS *) WrongUserError:< Exception (* Raised if something other than 'a', 'u', 'g', or 'o' * is specified for "who". Message: "Wrong user * specification for disk entry permission." *) (# ... #); WrongModeError:< Exception (* Raised if something other than 'r', 'w', or 'x' is * specified for "mode". Message: "Wrong mode * specification for disk entry permission." *) (# ... #); ChangePermError:< DiskEntryException (* Raised if a change of permissions has failed for * THIS(UnixEntry). Message: "Failed to change permission * for disk entry." *) (# ... #); OtherError:< DiskEntryException (* Raised if other errors occurred *); has: (* True if "who" has the "mode" access to * THIS(UnixEntry). *) (# mode,who: @char; result: @boolean; enter (who,mode) ... exit result #); add: (* Give "who" the "mode" access to THIS(UnixEntry) *) (# mode,who: @char; enter (who,mode) ... #); remove: (* Remove the "mode" from the way "who" may access * THIS(UnixEntry). *) (# mode,who: @char; enter (who,mode) ... #); #); (* permission *) device: IntegerValue (* Integer denoting the device on which the Inode of * THIS(UnixEntry) resides *) (# error:<DiskEntryException; ... #); inode: IntegerValue (* Unambigous integer denoting the identity of this unix entry *) (# error:<DiskEntryException; ... #); isCharSpecial: BooleanValue (# error:<DiskEntryException; ... #); isBlockSpecial: BooleanValue (# error:<DiskEntryException; ... #); isSymbolicLink: BooleanValue (* True if THIS(UnixEntry) is a symbolic link. Always false * if followlinks is set to true (default) *) (# error:<DiskEntryException; ... #); isSocket: BooleanValue (* True if THIS(UnixEntry) is a socket *) (# error:<DiskEntryException; ... #); hardLinks: IntegerValue (* Number of hard links to THIS(UnixEntry) *) (# error:<DiskEntryException; ... #); deviceType: IntegerValue (* If THIS(UnixEntry) is a device, the integer exited denotes * the type of the device *) (# error:<DiskEntryException; ... #); owner: (* Set/get the userid (an integer) denoting the identity of * the owner of THIS(UnixEntry) *) (# uid: @integer; error:<DiskEntryException; set: (# enter uid do ... #); get: (# ... exit uid #); enter set exit get #); group: (* Set/get the group id (an integer) denoting the identity of * the group to which the owner of THIS(UnixEntry) belongs *) (# gid: @integer; error:<DiskEntryException; set: (# enter gid do ... #); get: (# ... exit gid #); enter set exit get #); accessTime: IntegerValue (* The (system) time of the last read or write manipulation of * THIS(UnixEntry) *) (# error:<DiskEntryException; ... #); statusTime: IntegerValue (* System time of the last status change of * THIS(UnixEntry). In our case a status change occurs when the * following operations are activated on THIS(UnixEntry): * touch, permission.add, permission.remove *) (# error:<DiskEntryException; ... #); optimalBlockSize: IntegerValue (# error:<DiskEntryException; ... #); blocks: IntegerValue (* The actual number of blocks allocated for THIS(UnixEntry) *) (# error:<DiskEntryException; ... #); linkTo: (* Make THIS(UnixEntry) be a symbolic link to dst. The * 'exists' exception is raised if THIS(UnixEntry) allready * exists. *) (# dst: ^text; error:< DiskEntryException; exists:< UnixEntryExisted; link: ^UnixEntry; enter dst[] do ...; #); linkFrom: (* Make src be a symbolic link to THIS(UnixEntry). The * 'exists' exception is raised if src allready exists. If no * errors occur, link is a UnixEntry for the link, with * followlinks set to false. *) (# src: ^text; error:<DiskEntryException; exists:< UnixEntryExisted; link: ^UnixEntry; enter src[] do ...; exit link #); #); (* UnixEntry *) UnixFile: File (* BETA interface to disk files in UNIX *) (# <<SLOT UnixFileLib: attributes>>; EntryDesc::< UnixEntry; OpenExeWrite: (* Like OpenWrite, except that the file written will be * executable *) (# ... #); OpenExeAppend: (* Like OpenAppend, except that the file written will be * executable *) (# ... #); #)
4.1 Unixfile Interface | © 1990-2004 Mjølner Informatics |
[Modified: Sunday August 9th 1998 at 22:57]
|