Class procs
compiledFlavor: ATOM ~ $compiled;
CompiledMaintenanceProcs: PFSClass.MaintenanceProcs ~
NEW[PFSClass.MaintenanceProcsObject ¬ [
sweep: CompiledSweep,
validate: CompiledValidate
]];
CompiledSweep: PFSClass.SweepProc ~ {
PROC [h: FSHandle, seconds: CARD]
};
me:
REF
TEXT ~ "CompiledViewImpl";
CompiledValidate: PFSClass.ValidateProc ~ {
PROC [h: FSHandle] RETURNS [obsolete: BOOL, downMsg: ROPE]
last: REF ~ Atom.GetProp[$CompiledViewImpl, $LastRegistered];
RETURN [obsolete: last # NIL AND last # me, downMsg: NIL]
};
CompiledFileManipulationProcs: PFSClass.FileManipulationProcs ~
NEW[PFSClass.FileManipulationProcsObject ¬ [
delete: CompiledDelete,
enumerateForInfo: CompiledEnumerateForInfo,
enumerateForNames: CompiledEnumerateForNames,
fileInfo: CompiledFileInfo,
lookupName: CompiledLookupName,
rename: CompiledRename,
copy: CompiledCopy,
setAttributes: CompiledSetAttributes,
setByteCountAndUniqueID: CompiledSetByteCountAndUniqueID,
setClientProperty: CompiledSetClientProperty,
getClientProperty: CompiledGetClientProperty,
enumerateClientProperties: CompiledEnumerateClientProperties,
read: CompiledRead,
write: CompiledWrite,
open: CompiledOpen,
close: CompiledClose,
store: CompiledStore,
retrieve: CompiledRetrieve,
attach: CompiledAttach,
getInfo: CompiledGetInfo,
pfsNameToUnixName: CompiledPFSNameToUnixName,
caseSensitive: CompiledCaseSensitive
]];
CompiledDelete: PFSClass.DeleteProc ~ {
PROC [h: FSHandle, file: PATH, wantedUniqueID: UniqueID, proc: PFS.NameConfirmProc]
NotApplicable["Delete"];
};
GetNames:
PROC [h: FSHandle, pattern:
PATH]
RETURNS [
LIST
OF
REF
--ROPE--] ~ {
patternSans: PATH ~ IF PFSNames.ShortName[pattern].version.versionKind = numeric THEN pattern ELSE PFSNames.StripVersionNumber[pattern];
pat: ROPE ~ PFS.RopeFromPath[patternSans];
tab: SymTab.Ref ~ NARROW[h.data];
list: LIST OF REF ¬ NIL;
EachPair: SymTab.EachPairAction ~ {
PROC [key: Key, val: Val] RETURNS [quit: BOOL ← FALSE]
IF Rope.Match[pattern: pat, object: key, case: FALSE] THEN { list ¬ CONS[key, list] };
};
[] ¬ SymTab.Pairs[tab, EachPair];
list ¬ List.Sort[list];
RETURN [list]
};
CompiledEnumerateForInfo: PFSClass.EnumerateForInfoProc ~ {
PROC [h: FSHandle, pattern: PATH, proc: PFS.InfoProc, lbound: PATH, hbound: PATH]
tab: SymTab.Ref ~ NARROW[h.data];
list: LIST OF REF ~ GetNames[h, pattern];
FOR tail:
LIST
OF
REF ¬ list, tail.rest
UNTIL tail =
NIL
DO
key: ROPE ~ NARROW[tail.first];
data: Data ~ NARROW[SymTab.Fetch[tab, key].val];
IF NOT proc[fullFName: PFS.PathFromRope[key], attachedTo: NIL, uniqueID: data.uniqueID, bytes: data.nBytes, mutability: immutable, fileType: PFS.tUnspecified].continue THEN EXIT;
ENDLOOP;
};
CompiledEnumerateForNames: PFSClass.EnumerateForNamesProc ~ {
PROC [h: FSHandle, pattern: PATH, proc: PFS.NameProc, lbound: PATH, hbound: PATH]
tab: SymTab.Ref ~ NARROW[h.data];
list: LIST OF REF ~ GetNames[h, pattern];
FOR tail:
LIST
OF
REF ¬ list, tail.rest
UNTIL tail =
NIL
DO
key: ROPE ~ NARROW[tail.first];
data: Data ~ NARROW[SymTab.Fetch[tab, key].val];
IF NOT proc[PFS.PathFromRope[key]].continue THEN EXIT;
ENDLOOP;
};
CompiledFileInfo: PFSClass.FileInfoProc ~ {
PROC [h: FSHandle, file: PATH, wantedUniqueID: UniqueID] RETURNS [version: Version, attachedTo: PATH, bytes: INT, uniqueID: UniqueID, mutability: PFS.Mutability, fileType: PFS.FileType]
data: Data ¬ NameToData[h, PFS.RopeFromPath[file]];
IF data = NIL THEN PFSBackdoor.ProduceError[unknownFile, Rope.Concat[PFS.RopeFromPath[file], " not found."], file];
RETURN [
version: [none],
attachedTo: NIL,
uniqueID: data.uniqueID,
bytes: data.nBytes,
mutability: immutable,
fileType: PFS.tUnspecified
]
};
CompiledLookupName: PFSClass.LookupNameProc ~ {
PROC [h: FSHandle, file: PATH] RETURNS[PATH]
data: Data ¬ NameToData[h, PFS.RopeFromPath[file]];
IF data = NIL THEN PFSBackdoor.ProduceError[unknownFile, Rope.Concat[PFS.RopeFromPath[file], " not found."], file];
RETURN [file]
};
CompiledRename: PFSClass.RenameProc ~ {
PROC [h: FSHandle, fromFile: PATH, wantedUniqueID: UniqueID, toFile: PATH, createOptions: PFS.CreateOptions, proc: PFS.NameConfirmProc] RETURNS [done: BOOL ← FALSE]
RETURN [FALSE]
};
CompiledCopy: PFSClass.CopyProc ~ {
PROC [h: FSHandle, fromFile: PATH, wantedUniqueID: UniqueID, toFile: PATH, createOptions: PFS.CreateOptions, proc: PFS.NameConfirmProc] RETURNS [done: BOOL ← FALSE]
RETURN [FALSE]
};
CompiledSetAttributes: PFSClass.SetAttributesProc ~ {
PROC [h: FSHandle, file: OpenFile, attributes: PFS.CreateOptions]
NotApplicable["SetAttributes"];
};
CompiledSetByteCountAndUniqueID: PFSClass.SetByteCountAndUniqueIDProc ~ {
PROC [h: FSHandle, file: OpenFile, propertyName: ROPE, propertyValue: ROPE]
NotApplicable["SetByteCountAndUniqueID"];
};
CompiledSetClientProperty: PFSClass.SetClientPropertyProc ~ {
PROC [h: FSHandle, file: OpenFile, propertyName: ROPE, propertyValue: ROPE]
NotApplicable["SetClientProperty"];
};
CompiledGetClientProperty: PFSClass.GetClientPropertyProc ~ {
PROC [h: FSHandle, file: OpenFile, propertyName: ROPE] RETURNS [propertyValue: ROPE]
RETURN [NIL]
};
CompiledEnumerateClientProperties: PFSClass.EnumerateClientPropertiesProc ~ {
PROC [h: FSHandle, file: OpenFile, proc: PFS.PropProc]
};
CompiledRead:
UNSAFE
PROC [h: FSHandle, file: OpenFile, filePosition, nBytes:
CARD, toPtr:
LONG
POINTER, toStart:
CARD]
RETURNS [bytesRead:
INT] ~
UNCHECKED {
data: Data ~ NARROW[file.data];
bytesRead ¬ 0;
IF filePosition > data.nBytes
THEN PFSBackdoor.ProduceError[positionNotInFile, "positionNotInFile", file]
ELSE bytesRead ¬ Basics.ByteBlt[to: [blockPointer: toPtr, startIndex: toStart, stopIndexPlusOne: toStart+nBytes], from: [blockPointer: data.base, startIndex: filePosition, stopIndexPlusOne: data.nBytes]]
};
CompiledWrite:
PROC [h: FSHandle, file: OpenFile, filePosition, nBytes:
CARD, fromPtr:
LONG
POINTER, fromStart:
CARD]
RETURNS [bytesWritten:
INT] ~ {
bytesWritten ¬ 0;
NotApplicable["Write"];
};
CompiledOpen: PFSClass.OpenProc ~ {
PROC [h: FSHandle, file: PATH, wantedUniqueID: UniqueID, access: PFS.AccessOptions, checkFileType: BOOL, fileType: PFS.FileType, createOptions: PFS.CreateOptions] RETURNS [OpenFile]
IF access = read
THEN {
data: Data ¬ NameToData[h, PFS.RopeFromPath[file]];
IF debug THEN DebugPrint[what: "\nOpen.file", ref: file];
IF data =
NIL
OR (wantedUniqueID #
PFS.nullUniqueID
AND wantedUniqueID # data.uniqueID)
THEN { PFSBackdoor.ProduceError[unknownFile, Rope.Concat[PFS.RopeFromPath[file], " not found."], file] }
ELSE {
RETURN [
NEW[PFSClass.OpenFileObject ¬ [
fs: h,
fullFName: NIL,
attachedTo: NIL,
uniqueID: data.uniqueID,
bytes: data.nBytes,
mutability: immutable,
fileType: PFS.tUnspecified,
access: access,
state: open,
data: data
]]]
};
}
ELSE {
NotApplicable["non-read Open"];
};
ERROR;
};
CompiledClose: PFSClass.CloseProc ~ {
PROC [h: FSHandle, file: OpenFile]
};
CompiledStore: PFSClass.StoreProc ~ {
PROC [h: FSHandle, file: PATH, wantedUniqueID: UniqueID, str: IO.STREAM, proc: PFS.StoreConfirmProc, createOptions: PFS.CreateOptions]
NotApplicable["Store"];
};
CompiledRetrieve: PFSClass.RetrieveProc ~ {
PROC [h: FSHandle, file: PATH, wantedUniqueID: UniqueID, proc: PFS.RetrieveConfirmProc, checkFileType: BOOL ← FALSE, fileType: PFS.FileType]
NotApplicable["Retrieve"];
};
CompiledAttach: PFSClass.AttachProc ~ {
PROC [h: FSHandle, file: PATH, to: PATH, keep: CARDINAL, wantedUniqueID: UniqueID, remoteCheck: BOOL ← TRUE] RETURNS [toFName: PATH]
NotApplicable["Attach"];
};
CompiledGetInfo: PFSClass.GetInfoProc ~ {
PROC [h: FSHandle, file: OpenFile] RETURNS [fullFName, attachedTo: PATH, uniqueID: UniqueID, bytes: INT, mutability: PFS.Mutability, fileType: PFS.FileType]
data: Data ~ NARROW[file.data];
RETURN [fullFName: file.fullFName, attachedTo: file.attachedTo, uniqueID: file.uniqueID, bytes: data.nBytes, mutability: file.mutability, fileType: file.fileType]
};
CompiledPFSNameToUnixName: PFSClass.PFSNameToUnixNameProc ~ {
PROC [h: FSHandle, file: PATH] RETURNS [ROPE]
RETURN [NIL]
};
CompiledCaseSensitive: PFSClass.CaseSensitiveProc ~ {
PROC [h: FSHandle, file: PATH] RETURNS [BOOL]
RETURN [FALSE]
};
fsToTable: SymTab.Ref ~ SymTab.Create[case:
FALSE];
CompiledGetHandle: PFSClass.GetHandleProc ~ {
PROC [fs: ROPE, flavorSpecified: BOOL] RETURNS [h: FSHandle, downMsg: ROPE]
nameToData: SymTab.Ref;
DoUpdate: SymTab.UpdateAction ~ {
PROC [found: BOOL, val: Val] RETURNS [op: UpdateOperation ← none, new: Val ← NIL];
IF found
THEN nameToData ¬ NARROW[val]
ELSE { op ¬ store; new ¬ nameToData ¬ SymTab.Create[case: FALSE] };
};
SymTab.Update[fsToTable, fs, DoUpdate];
downMsg ¬ NIL;
IF debug THEN DebugPrint[what: "\nCompiledGetHandle.fs", ref: fs];
IF debug THEN DebugPrint[what: "\nCompiledGetHandle.flavorSpecified", ref: IF flavorSpecified THEN "TRUE" ELSE "FALSE"];
IF debug THEN DebugPrint[what: "\nCompiledGetHandle.nameToData", ref: nameToData];
h ¬
NEW [PFSClass.FSObject ¬ [
flavor: compiledFlavor,
name: fs,
maintenanceProcs: CompiledMaintenanceProcs,
procs: CompiledFileManipulationProcs,
data: nameToData
]];
};