Esempio n. 1
0
Bit8u DOS_FCBRandomWrite(Bit16u seg,Bit16u offset,Bit16u * numRec,bool restore) {
    /* see FCB_RandomRead */
    DOS_FCB fcb(seg,offset);
    Bit32u random;
    Bit16u old_block=0;
    Bit8u old_rec=0;
    Bit8u error=0;
    Bit16u count;

    /* Set the correct record from the random data */
    fcb.GetRandom(random);
    fcb.SetRecord((Bit16u)(random / 128),(Bit8u)(random & 127));
    if (restore) fcb.GetRecord(old_block,old_rec);
    if (*numRec > 0) {
        /* Write records */
        for (count=0; count<*numRec; count++) {
            error = DOS_FCBWrite(seg,offset,count);// dos_fcbwrite return 0 false when true...
            if (error!=FCB_SUCCESS) break;
        }
        *numRec=count;
    } else {
        DOS_FCBIncreaseSize(seg,offset);
    }
    Bit16u new_block;
    Bit8u new_rec;
    fcb.GetRecord(new_block,new_rec);
    if (restore) fcb.SetRecord(old_block,old_rec);
    /* Update the random record pointer with new position only when restore is false */
    if (!restore) fcb.SetRandom(new_block*128+new_rec);
    return error;
}
Esempio n. 2
0
Bit8u DOS_FCBRandomWrite(Bit16u seg, Bit16u offset, Bit16u numRec, bool restore)	// See FCB_RandomRead
	{
	DOS_FCB fcb(seg,offset);
	Bit32u random;
	Bit16u old_block = 0;
	Bit8u old_rec = 0;
	Bit8u error = 0;

	fcb.GetRandom(random);															// Set the correct record from the random data
	fcb.SetRecord((Bit16u)(random / 128), (Bit8u)(random & 127));
	if (restore)
		fcb.GetRecord(old_block, old_rec);
	if (numRec > 0)
		for (int i = 0; i < numRec; i++)											// Write records
			{
			error = DOS_FCBWrite(seg, offset, (Bit16u)i);							// DOS_fcbwrite return 0 false when true...
			if (error != 0)
				break;
			}
	else
		DOS_FCBIncreaseSize(seg, offset);
	Bit16u new_block;
	Bit8u new_rec;
	fcb.GetRecord(new_block, new_rec);
	if (restore)
		fcb.SetRecord(old_block, old_rec);
	else
		fcb.SetRandom(new_block*128+new_rec);										// Update the random record pointer with new position only when restore is false
	return error;
	}