// FSParams.Bcpl -- Spruce Files -- set file system-dependent parameters

get "sprucefiles.d"
get "altofilesys.d"
get "disks.d"
get "tfs.d"

external // Defined here
	[
	TfsParams
	BfsParams
	SetWorkingDir
	// ~~ Until appearances are established in Sys.bk
//	DefaultBfsErrorRtn
//	BFSNonEx
	]

external [
// From BFS
	BfsDoDiskCommand; BfsGetCb; BfsInitializeCbStorage; DefaultBfsErrorRtn
// From TFS
	TFSDoDiskCommand; TFSGetCb; TFSInitializeCbStorage; DefaultTFSErrorRtn
// From OS
	sysDisk; MoveBlock; //SysErr
	]

manifest [ M31NextCommand = #521; T80NextCommand = #640 ]

// Set up offsets, lengths, routines, etc., for TFS and BFS -- all similar, none matching
let TfsParams() = valof
	[
	let fParams = table [ 0; 0; 0; 0; lCB; lTFSCBZ;
			      offset CBZ.cleanupRoutine/16; offset CBZ.retry/16;
			      offset CB.AddrL/16; offset DL.numChars/16; T80NextCommand ]
	if fParams>>FParams.InitializeCbStorage resultis fParams
	fParams>>FParams.InitializeCbStorage = TFSInitializeCbStorage
	fParams>>FParams.GetCb = TFSGetCb
	fParams>>FParams.DoDiskCommand = TFSDoDiskCommand
	fParams>>FParams.lvDefaultErrorRtn = lv DefaultTFSErrorRtn
	resultis fParams
	]

get "bfs.d"

let BfsParams() = valof
	[
	let fParams = table [ 0; 0; 0; 0; lCB; lBFSCBZ;
			      offset CBZ.cleanupRoutine/16; offset CBZ.retry/16;
			      offset CB.labelAddress/16; offset DL.numChars/16; M31NextCommand ]
	if fParams>>FParams.InitializeCbStorage resultis fParams
	fParams>>FParams.InitializeCbStorage = BfsInitializeCbStorage
	fParams>>FParams.GetCb = BfsGetCb
	fParams>>FParams.DoDiskCommand = BfsDoDiskCommand
	fParams>>FParams.lvDefaultErrorRtn = lv DefaultBfsErrorRtn
	resultis fParams
	]

// ------------------------------------------------------
and SetWorkingDir(name, fp, disk; numargs na) be // Extracted from Os16.1 Dirs.bcpl
// ------------------------------------------------------
[
if na ls 3 then disk = sysDisk
MoveBlock(disk>>DSK.fpWorkingDir, fp, lFP)
MoveBlock(disk>>DSK.nameWorkingDir, name, maxLengthFnInWords)
]

// ~~ Until available via Sys.Bk
//and DefaultBfsErrorRtn(addr, cb, errNo) be
//	SysErr(0, ecUnRecovDiskError, cb)

//and BFSNonEx(disk) be
//	SysErr(disk, ecNoCreationAbility)
// ~~

// DCS, October 31, 1978  11:36 PM, created
// November 2, 1978  7:57 AM, add SetWorkingDir
// November 3, 1978  8:43 AM, change last param to cb list loc
// February 20, 1979  3:16 PM, add DefaultBfsErrorRtn, BFSNonEx ~~ temporarily
// September 20, 1979  4:06 PM, (OS17) DefaultBfsErrorRtn, BFSNonEx available via Sys.bk
//