Fix FCB problems with int21/ah=27,28 (RandomBlockIO)

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@715 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2003-10-11 23:58:51 +00:00
parent 11e163096d
commit fdb58291c4
3 changed files with 16 additions and 9 deletions

View File

@ -337,19 +337,26 @@ void FcbCalcRec(xfcb FAR * lpXfcb)
lpFcb->fcb_curec = lpFcb->fcb_rndm & 127;
}
UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, COUNT nRecords, int mode)
UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode)
{
UCOUNT recno = 0;
UBYTE nErrorCode;
unsigned recno;
UBYTE nErrorCode = FCB_SUCCESS;
FcbCalcRec(lpXfcb);
/* Convert to fcb if necessary */
lpFcb = ExtFcbToFcb(lpXfcb);
do
nErrorCode = FcbReadWrite(lpXfcb, recno++, mode);
while ((--nRecords > 0) && (nErrorCode == 0));
for (recno = 0; recno < *nRecords; recno++)
{
nErrorCode = FcbReadWrite(lpXfcb, recno, mode);
/* end-of-file, partial read should count last record */
if (nErrorCode == FCB_ERR_EOF)
recno++;
if (nErrorCode != FCB_SUCCESS)
break;
}
*nRecords = recno;
/* Now update the fcb */
lpFcb->fcb_rndm = FcbRec();

View File

@ -658,12 +658,12 @@ dispatch:
/* Read random record(s) using FCB */
case 0x27:
lr.AL = FcbRandomBlockIO(FP_DS_DX, lr.CX, XFR_READ);
lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_READ);
break;
/* Write random record(s) using FCB */
case 0x28:
lr.AL = FcbRandomBlockIO(FP_DS_DX, lr.CX, XFR_WRITE);
lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_WRITE);
break;
/* Parse File Name */

View File

@ -210,7 +210,7 @@ const BYTE FAR *GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestField
UBYTE FcbReadWrite(xfcb FAR *, UCOUNT, int);
UBYTE FcbGetFileSize(xfcb FAR * lpXfcb);
void FcbSetRandom(xfcb FAR * lpXfcb);
UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, COUNT nRecords, int mode);
UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode);
UBYTE FcbRandomIO(xfcb FAR * lpXfcb, int mode);
UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags);
int FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive);