File Manipulation Procs
XNSDelete:
PROC ~ {
<<
fileH: FilingP10V5.Handle; withKids: BOOL;
[fileH: fileH, withKids: withKids] ← FindFile[mnt, crH, file, wantedUniqueID, $delete];
IF ( withKids )
THEN {
ENABLE
UNWIND => {
mnt.session.verifier ← XNSAuth.GetNextVerifier[mnt.conversation];
FilingP10V5.Close[h: crH, file: fileH, session: mnt.session^];
};
xx: ROPE ~ IO.PutFR["Directory %g has children", IO.rope[file] ];
PFSBackdoor.ProduceError[accessDenied, xx]
};
{
delete: BOOL ← IF ( proc = NIL ) THEN TRUE ELSE proc[fullName, uniqueID];
IF ( delete )
THEN {
mnt.session.verifier ← XNSAuth.GetNextVerifier[mnt.conversation];
FilingP10V5.Delete[h: crH, file: fileH, session: mnt.session^];
mnt.session.verifier ← XNSAuth.GetNextVerifier[mnt.conversation];
FilingP10V5.Close[h: crH, file: fileH, session: mnt.session^];
};
};
mnt.active ← FALSE; ReturnConnection[crH];
>>
};
Delete: PFSClass.DeleteProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
DeleteInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
fullName: PFSNames.PATH ← NIL;
uniqueID: PFS.UniqueID ← PFS.nullUniqueID;
continue: BOOL ← IF ( proc = NIL ) THEN TRUE ELSE proc[fullName, uniqueID];
};
CallProtected[mnt, DeleteInner];
};
XNSEnumerateForInfo:
PROC ~ {
<<
P:
PROC [file:
ROPE, bytes:
INT, created: BasicTime.
GMT, fileType: FileType, version: Version, fID: FileID, isDir:
BOOL, withKids:
BOOL, pathName:
REF
TEXT]
RETURNS [continue:
BOOL] = {
continue ← proc[file, bytes, created, fileType];
};
InnerEnumerate[h, pattern, FALSE, P, $enumerate];
>>
};
EnumerateForInfo: PFSClass.EnumerateForInfoProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
EnumerateForInfoInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
fullFName: PFSNames.PATH ← NIL;
attachedTo: PFSNames.PATH ← NIL;
uniqueID: PFS.UniqueID ← PFS.nullUniqueID;
bytes: INT ← 0;
mutability: PFS.Mutability ← immutable;
fileType: PFS.FileType ← PFS.tUnspecified;
continue: BOOL ← IF ( proc = NIL ) THEN TRUE ELSE
proc[fullFName, attachedTo, uniqueID, bytes, mutability, fileType];
};
CallProtected[mnt, EnumerateForInfoInner];
};
EnumerateForNames: PFSClass.EnumerateForNamesProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
EnumerateForNamesInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
name: PFSNames.PATH;
continue: BOOL ← IF ( proc = NIL ) THEN TRUE ELSE proc[name];
};
CallProtected[mnt, EnumerateForNamesInner];
};
FileInfo: PFSClass.FileInfoProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
FileInfoInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
version ← [none];
attachedTo ← NIL;
bytes ← 0;
uniqueID ← PFS.nullUniqueID;
mutability ← immutable;
fileType ← PFS.tUnspecified;
};
CallProtected[mnt, FileInfoInner];
};
Lookup: PFSClass.LookupNameProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
path: PFSNames.PATH;
LookupInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
path ← NIL;
};
CallProtected[mnt, LookupInner];
RETURN[path];
};
Rename: PFSClass.RenameProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
RenameInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
done ← TRUE;
};
CallProtected[mnt, RenameInner];
};
Copy: PFSClass.CopyProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
CopyInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
done ← TRUE;
};
CallProtected[mnt, CopyInner];
};
SetAttributes: PFSClass.SetAttributesProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
SetAttributesInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
NULL;
};
CallProtected[mnt, SetAttributesInner];
};
SetByteCountAndUniqueID: PFSClass.SetByteCountAndUniqueIDProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
SetByteCountAndUniqueIDInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
NULL;
};
CallProtected[mnt, SetByteCountAndUniqueIDInner];
};
SetClientProperty: PFSClass.SetClientPropertyProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
SetClientPropertyInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
NULL;
};
CallProtected[mnt, SetClientPropertyInner];
};
GetClientProperty: PFSClass.GetClientPropertyProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
GetClientPropertyInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
propertyValue ← NIL;
};
CallProtected[mnt, GetClientPropertyInner];
};
EnumerateClientProperties: PFSClass.EnumerateClientPropertiesProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
EnumerateClientPropertiesInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
propertyName: ROPE; propertyValue: ROPE;
continue: BOOL ← IF ( proc = NIL ) THEN TRUE ELSE proc[propertyName, propertyValue];
};
CallProtected[mnt, EnumerateClientPropertiesInner];
};
Open: PFSClass.OpenProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
of: PFSClass.OpenFile;
OpenInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
of ← NIL;
};
CallProtected[mnt, OpenInner];
RETURN[of];
};
Read: PFSClass.ReadProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
ReadInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
bytesRead ← 0;
};
CallProtected[mnt, ReadInner];
};
Write: PFSClass.WriteProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
WriteInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
bytesWritten ← 0;
};
CallProtected[mnt, WriteInner];
};
Close: PFSClass.CloseProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
CloseInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
NULL;
};
CallProtected[mnt, CloseInner];
};
Store: PFSClass.StoreProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
StoreInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
fullName: PFSNames.PATH ← NIL;
continue: BOOL ← IF ( proc = NIL ) THEN TRUE ELSE proc[fullName];
};
CallProtected[mnt, StoreInner];
};
Retrieve: PFSClass.RetrieveProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
RetrieveInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
fullFName: PFSNames.PATH ← NIL;
bytes: INT ← 0;
uniqueID: PFS.UniqueID ← PFS.nullUniqueID;
s: IO.STREAM ← IF ( proc = NIL ) THEN NIL ELSE proc[fullFName, bytes, uniqueID];
IF ( s = NIL ) THEN ERROR;
};
CallProtected[mnt, RetrieveInner];
};
Attach: PFSClass.AttachProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
AttachInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
toFName ← NIL;
};
CallProtected[mnt, AttachInner];
};
GetInfo: PFSClass.GetInfoProc ~ {
class: PFSClass.FSHandle ~ h;
mnt: VFS ~ NARROW[class.data];
GetInfoInner: TransportProc ~ {
ENABLE UNWIND => { NULL };
fullFName ← NIL;
attachedTo ← NIL;
uniqueID ← PFS.nullUniqueID;
bytes ← 0;
mutability ← immutable;
fileType ← PFS.tUnspecified;
};
CallProtected[mnt, GetInfoInner];
};
}.