MakeDoFiles.Mesa
Last Edited by: Spreitzer, February 18, 1986 2:55:19 pm PST
DIRECTORY Basics, CedarProcess, FS, FSBackdoor, IO, MakeDo, PrincOpsUtils, Process, RedBlackTree, Rope, UserProfile, ViewerClasses, ViewerIO;
MakeDoFiles: CEDAR PROGRAM
IMPORTS CedarProcess, FS, FSBackdoor, MakeDo, Rope, UserProfile
EXPORTS MakeDo
=
BEGIN OPEN MakeDo;
fileClass: PUBLIC NodeClass ← DeclareNodeClass[
name: "file",
CanonizeName: CannonizeFileName,
GetTime: GetFileTime
];
CannonizeFileName: PROC [random: ROPE] RETURNS [canonical: ROPE] = {
full: ROPE;
cp: FS.ComponentPositions;
[full, cp] ← FS.ExpandName[random];
canonical ← full.Substr[len: cp.ext.start + cp.ext.length];
};
GetFileTime: PUBLIC PROC [n: Node] RETURNS [created: Time] --GetTimeProc-- =
BEGIN
name: ROPE = n.PublicPartsOfNode[].name;
FileViewerOps.WaitUntilSaved[fileName: n.name, feedBack: GetCommanderHandle[].err];
[created: created] ← FS.FileInfo[name !FS.Error =>
{created ← notExistTime; CONTINUE}];
END;
fsWatchEnabled: BOOLTRUE;
logFSWatch: BOOLFALSE;
firstLocal: REF READONLY FSBackdoor.CreateEvent ← NIL;
firstRemote: REF READONLY FSBackdoor.RemoteEvent ← NIL;
WatchFSLocal: PROC [REF ANY] RETURNS [REF ANYNIL] = {
ce: REF READONLY FSBackdoor.CreateEvent ← NIL;
WHILE fsWatchEnabled DO
ce ← FSBackdoor.NextCreateEvent[ce];
IF logFSWatch AND firstLocal=NIL THEN firstLocal ← ce;
{ENABLE ABORTED => CONTINUE;
n: Node ← GetNode[ce.fName, fileClass, FALSE];
IF n # NIL THEN {
SuspectNodeChange[n];
};
};
ENDLOOP;
ce ← ce;
};
WatchFSRemote: PROC [REF ANY] RETURNS [REF ANYNIL] = {
re: REF READONLY FSBackdoor.RemoteEvent ← NIL;
WHILE fsWatchEnabled DO
re ← FSBackdoor.NextRemoteEvent[re];
IF logFSWatch AND firstRemote=NIL THEN firstRemote ← re;
{ENABLE ABORTED => CONTINUE;
n: Node ← GetNode[re.fName, fileClass, FALSE];
IF n # NIL THEN {
SuspectNodeChange[n];
};
};
ENDLOOP;
re ← re;
};
localWatcher, remoteWatcher: CedarProcess.Process;
NoteProfile: PROC [reason: UserProfile.ProfileChangeReason] --UserProfile.ProfileChangedProc-- = {
logFSWatch ← UserProfile.Boolean["MakeDo.LogFSWatch", FALSE];
};
Start: PROC = {
UserProfile.CallWhenProfileChanges[NoteProfile];
localWatcher ← CedarProcess.Fork[action: WatchFSLocal, options: [inheritProperties: TRUE]];
remoteWatcher ← CedarProcess.Fork[action: WatchFSRemote, options: [inheritProperties: TRUE]];
};
Start[];
END.