MakeDoFiles.Mesa
Last Edited by: Spreitzer, February 20, 1986 10:01:12 pm PST
JKF January 11, 1989 10:10:14 am PST
Eduardo Pelegri-Llopart March 17, 1989 8:41:25 am PST
Last tweaked by Mike Spreitzer on October 5, 1992 12:35 pm PDT
DIRECTORY
FS USING [ComponentPositions, Error, ExpandName, FileInfo],
MakeDo USING [DeclareNodeClass, existsFSWatch, Node, NodeClass, notExistTime, PublicPartsOfNode, Time],
MakeDoPorting USING [StartFSWatchers],
Rope USING [ROPE, Substr];
MakeDoFiles: CEDAR MONITOR
IMPORTS FS, MakeDo, MakeDoPorting, Rope
EXPORTS MakeDo
=
BEGIN OPEN MakeDo;
ROPE: TYPE = Rope.ROPE;
fileClass: PUBLIC NodeClass ← DeclareNodeClass[
name: "file",
CanonizeName: CannonizeFileName,
GetInfo: GetFileInfo
];
CannonizeFileName: PROC [random: ROPE] RETURNS [canonical: ROPE] = {
ENABLE FS.Error => {canonical ← random; CONTINUE};
full: ROPE;
cp: FS.ComponentPositions;
[full, cp] ← FS.ExpandName[random];
canonical ← full.Substr[len: cp.ext.start + cp.ext.length];
};
GetFileInfo: PUBLIC PROC [n: Node] RETURNS [created: Time, length: INT] --GetTimeProc-- ~ {
name: ROPE = n.PublicPartsOfNode[].name;
[created: created, bytes: length] ← FS.FileInfo[name: name, remoteCheck: TRUE --we need this to get the byte count, which we need to check for broken attachments-- !FS.Error =>
{created ← notExistTime; CONTINUE}];
IF length = -1 THEN created ← notExistTime;
RETURN};
IF existsFSWatch THEN MakeDoPorting.StartFSWatchers[];
END.