DeclareSegment:
PUBLIC
PROC[filePath:
ROPE, segment: Segment, number: DBCommon.SegmentIndex, lock: AlpineEnvironment.LockOption, readonly:
BOOL, createIfNotFound:
BOOL, nPagesInitial, nPagesPerExtent:
INT] = {
fileVersion: DBStorage.VersionOptions = IF readonly OR NOT createIfNotFound THEN OldFileOnly ELSE None;
nameComponents: FS.ComponentPositions;
server, baseName: Rope.ROPE;
IF NOT initialized THEN ERROR DB.Error[DatabaseNotInitialized];
[fullFName ~ filePath, cp ~ nameComponents] ← FS.ExpandName[name: filePath, wDir: "///"];
server ← Rope.Substr[filePath, nameComponents.server.start, nameComponents.server.length];
baseName ← Rope.Substr[filePath, nameComponents.base.start, nameComponents.base.length];
IF Rope.Length[server] = 0 OR Rope.Length[baseName] = 0 THEN ERROR DB.Error[IllegalFileName];
IF segment = NIL THEN segment ← Atom.MakeAtom[baseName];
IF number= 0 THEN number ← MapSegmentToNumber[segment];
Save away the server name for future reference
BEGIN
handle: SegmentHandle ← SegmentToHandle[segment];
newAttachment: BOOL = DBStorage.AttachSegment[filePath, segment, number, lock, readonly, fileVersion, nPagesInitial, nPagesPerExtent];
IF NOT newAttachment THEN RETURN;
handle.server ← server;
handle.cacheTrashed ← TRUE; -- whatever is hanging around in the schema cache for the segment will become invalid when the next transaction is opened
END };
EraseSegment:
PUBLIC
PROC[segment: Segment, useTrans: TransactionHandle]
RETURNS [trans: TransactionHandle] = {
RETURN[OpenTransaction[segment: segment, useTrans: useTrans, eraseAfterOpen: TRUE].trans] };
segmentArray:
ARRAY [0..builtinSegmentCount)
OF SegmentAndIndex =
[ [$Icons, 140B], [$Walnut, 200B], [$Nuthatch, 250B], [$Finger, 260B], [$Test, 300B], [$Whiteboard, 310B], [$Tool, 320B], [$WalnutSortDef, 330B]
reserve [330B .. 350B) for Pasadena
];