DIRECTORY FS, Random, Rope, VM; FileExtendTester: CEDAR PROGRAM IMPORTS FS, Random, VM = BEGIN DoTest: PROC [fileName: Rope.ROPE, numberOfExtends: INT ] = { vmBuffer: VM.Interval _ VM.nullInterval; { ENABLE UNWIND => IF vmBuffer # VM.nullInterval THEN TRUSTED { VM.Free[vmBuffer ! VM.AddressFault => CONTINUE;]; }; file: FS.OpenFile; sizeNow: INT _ 100; offset: INT _ 0; dummy1, dummy2: INT _ 0; bufferPointer: LONG POINTER; randomStream: Random.RandomStream; file _ FS.Create[name: fileName, setPages: TRUE, pages: sizeNow, setKeep: TRUE, keep: 100]; randomStream _ Random.Create[range: 10000, seed: -1] ; offset _ Random.ChooseInt[randomStream, 1, 10000]; vmBuffer _ VM.Allocate[count: 1]; TRUSTED { bufferPointer _ VM.AddressForPageNumber[vmBuffer.page]; }; FOR page: INT IN [0..sizeNow) DO intBuffer: LONG POINTER TO ARRAY [0..8) OF INT = LOOPHOLE[bufferPointer]; TRUSTED { intBuffer[0] _ offset+page;}; file.Write[to: page, nPages: 1, from: bufferPointer]; ENDLOOP; TRUSTED { FOR page: INT IN [0..sizeNow) DO intBuffer: LONG POINTER TO ARRAY [0..8) OF INT = bufferPointer; intBuffer[0] _ -1; file.Read[from: page, nPages: 1, to: bufferPointer]; IF intBuffer[0] # offset+page THEN ERROR; ENDLOOP; }; FOR extent: INT IN [0..numberOfExtends) DO intBuffer: LONG POINTER TO ARRAY [0..8) OF INT = LOOPHOLE[bufferPointer]; TRUSTED { intBuffer[0] _ offset+sizeNow;}; sizeNow _ sizeNow + 1; file.SetPageCount[sizeNow]; file.Write[to: sizeNow-1, nPages: 1, from: bufferPointer]; ENDLOOP; file.SetByteCountAndCreatedTime[bytes: FS.BytesForPages[sizeNow]]; TRUSTED { FOR page: INT IN [0..sizeNow) DO intBuffer: LONG POINTER TO ARRAY [0..8) OF INT = bufferPointer; intBuffer[0] _ -1; file.Read[from: page, nPages: 1, to: bufferPointer]; IF intBuffer[0] # offset+page THEN ERROR; ENDLOOP; }; file.Close[]; dummy1 _ sizeNow; dummy2 _ sizeNow; }; }; CheckFile: PROC [fileName: Rope.ROPE ] = { vmBuffer: VM.Interval _ VM.nullInterval; { ENABLE UNWIND => IF vmBuffer # VM.nullInterval THEN TRUSTED { VM.Free[vmBuffer ! VM.AddressFault => CONTINUE;]; }; file: FS.OpenFile; size: INT _ 100; offset: INT _ 0; dummy1, dummy2: INT _ 0; bufferPointer: LONG POINTER; file _ FS.Open[name: fileName, lock: write]; vmBuffer _ VM.Allocate[count: 1]; TRUSTED { bufferPointer _ VM.AddressForPageNumber[vmBuffer.page]; }; [pages: size] _ file.GetInfo[]; TRUSTED { FOR page: INT IN [0..size) DO intBuffer: LONG POINTER TO ARRAY [0..8) OF INT = bufferPointer; intBuffer[0] _ -1; file.Read[from: page, nPages: 1, to: bufferPointer]; IF page = 0 THEN offset _ intBuffer[0] ELSE { IF intBuffer[0] # offset+page THEN ERROR; }; ENDLOOP; }; file.SetPageCount[size+1]; file.SetPageCount[size]; file.Close[]; dummy1 _ size; dummy2 _ size; }; }; END. dFileExtendTester.mesa Last Edited by: Bob Hagmann, April 1, 1985 12:22:14 pm PST Start code Êv˜Icode1šœ™™K™*—šÏk ˜ J˜Jšœ˜Kšœ˜Kšœ˜—šœœ˜Kšœ˜Kšœ˜K˜K˜K˜K˜šÐbnœœœœ˜=Kšœ œ œ ˜(˜š œœœ œœœ˜=Kšœœœ˜1K˜—Kšœœ ˜Kšœ œ˜Kšœœ˜Kšœœ˜Kšœœœ˜Kšœ"˜"Kšœœ"œœ ˜[Kšœ6˜6Kšœ2˜2Kšœ œ˜!Kšœœ(˜Dšœœœ˜ Kšœ œœœœœœœ˜IKšœ ˜'Kšœ5˜5Kšœ˜—šœ˜ šœœœ˜ Kš œ œœœœœœ˜?Kšœ˜Kšœ4˜4Kšœœœ˜)Kšœ˜—K˜—šœ œœ˜*Kšœ œœœœœœœ˜IKšœ#˜*K˜Kšœ˜Kšœ:˜:Kšœ˜—Kšœ'œ˜Bšœ˜ šœœœ˜ Kš œ œœœœœœ˜?Kšœ˜Kšœ4˜4Kšœœœ˜)Kšœ˜—K˜—K˜ Kšœ˜Kšœ˜K˜—K˜—K˜šž œœœ˜*Kšœ œ œ˜(˜š œœœ œœœ˜=Kšœœœ˜1K˜—Kšœœ ˜Kšœœ˜Kšœœ˜Kšœœ˜Kšœœœ˜Kšœœ#˜,Kšœ œ˜!Kšœœ(˜DKšœ˜šœ˜ šœœœ ˜Kš œ œœœœœœ˜?Kšœ˜Kšœ4˜4šœ œœ˜-Kšœœœ˜)K˜—Kšœ˜—K˜—Kšœ˜Kšœ˜K˜ Kšœ˜Kšœ˜K˜—K˜—K˜K˜K˜K˜K™ K˜K˜Kšœ˜K™—K˜J˜—…— ª„