//MDload0 -- scan Micro binaries for write date
// last edited November 29, 1979  4:37 PM

	get "mddecl.d"
	get "altofilesys.d"
	get "disks.d"
	get "time.d"

external	// defined here
[	Load0	// (sources, outs, tempzone, zone)
		// statics
	sourceNameWidth
]

external
[		// OS
	Allocate
	BFSActOnPages
	Free
	MoveBlock
	sysDisk
		// TIME
	UNPACKDT
	CONVUDT
		// MDload
	Load
]


static [ sourceNameWidth = 0 ]


let Load0(sources, outs, tempzone, zone) be
	Load(sources, outs, tempzone, zone, LoadFile0)

and LoadFile0(source, outs, tempzone, zone) be
[	let w = source>>Source.pName>>BS.length
	if w gr sourceNameWidth then sourceNameWidth = w
	let fp = source>>Source.pFP
	let DAs = vec 1
	DAs!0, DAs!1 = fp>>FP.leaderVirtualDa, fillInDA
	let lnPageSize = sysDisk>>DSK.lnPageSize
	let pageSize = 1 lshift lnPageSize
	let leader = Allocate(tempzone, pageSize)
	BFSActOnPages(sysDisk, 0, DAs, fp, 0, 0, DCreadD, 0, 0, leader, 0, 0, true)	// read the leader page
	let t = vec lTIME
	MoveBlock(t, lv leader>>LD.written, lTIME)
	if @t eq 0 then MoveBlock(t, lv leader>>LD.created, lTIME)
	let utv = vec lenUTV
	UNPACKDT(t, utv)
	let ws = vec 20
	CONVUDT(ws, utv)
	let nw = ws>>BS.length rshift 1 + 1
	let date = Allocate(zone, nw)
	MoveBlock(date, ws, nw)
	source>>Source.pDate = date
	Free(tempzone, leader, pageSize)
]