mirror of https://github.com/FDOS/kernel.git
Divide optimisation (ceiling) + some small cleanups
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@717 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
61d87d82bb
commit
dd9df1f3a6
|
@ -251,11 +251,11 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode)
|
||||||
|
|
||||||
if ((ULONG)recno * lpFcb->fcb_recsiz >= 0x10000ul ||
|
if ((ULONG)recno * lpFcb->fcb_recsiz >= 0x10000ul ||
|
||||||
FP_OFF(FcbIoPtr) < FP_OFF(dta))
|
FP_OFF(FcbIoPtr) < FP_OFF(dta))
|
||||||
return FCB_ERR_SEGMENT_WRAP;
|
return FCB_ERR_SEGMENT_WRAP;
|
||||||
|
|
||||||
/* Convert to fcb if necessary */
|
/* Convert to fcb if necessary */
|
||||||
lpFcb = ExtFcbToFcb(lpXfcb);
|
lpFcb = ExtFcbToFcb(lpXfcb);
|
||||||
|
|
||||||
/* Now update the fcb and compute where we need to position */
|
/* Now update the fcb and compute where we need to position */
|
||||||
/* to. */
|
/* to. */
|
||||||
lPosit = FcbRec(lpFcb) * lpFcb->fcb_recsiz;
|
lPosit = FcbRec(lpFcb) * lpFcb->fcb_recsiz;
|
||||||
|
@ -266,7 +266,7 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode)
|
||||||
nTransfer = DosRWSft(lpFcb->fcb_sftno, lpFcb->fcb_recsiz, FcbIoPtr, mode);
|
nTransfer = DosRWSft(lpFcb->fcb_sftno, lpFcb->fcb_recsiz, FcbIoPtr, mode);
|
||||||
if (nTransfer < 0)
|
if (nTransfer < 0)
|
||||||
CritErrCode = -(int)nTransfer;
|
CritErrCode = -(int)nTransfer;
|
||||||
|
|
||||||
/* Now find out how we will return and do it. */
|
/* Now find out how we will return and do it. */
|
||||||
if (nTransfer == lpFcb->fcb_recsiz)
|
if (nTransfer == lpFcb->fcb_recsiz)
|
||||||
{
|
{
|
||||||
|
@ -286,12 +286,14 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode)
|
||||||
UBYTE FcbGetFileSize(xfcb FAR * lpXfcb)
|
UBYTE FcbGetFileSize(xfcb FAR * lpXfcb)
|
||||||
{
|
{
|
||||||
int FcbDrive, sft_idx;
|
int FcbDrive, sft_idx;
|
||||||
|
unsigned recsiz;
|
||||||
|
|
||||||
/* Build a traditional DOS file name */
|
/* Build a traditional DOS file name */
|
||||||
fcb FAR *lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
|
fcb FAR *lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
|
||||||
|
recsiz = lpFcb->fcb_recsiz;
|
||||||
|
|
||||||
/* check for a device */
|
/* check for a device */
|
||||||
if (!lpFcb || IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0))
|
if (!lpFcb || IsDevice(SecPathName) || (recsiz == 0))
|
||||||
return FCB_ERROR;
|
return FCB_ERROR;
|
||||||
|
|
||||||
sft_idx = (short)DosOpenSft(SecPathName, O_LEGACY | O_RDONLY | O_OPEN, 0);
|
sft_idx = (short)DosOpenSft(SecPathName, O_LEGACY | O_RDONLY | O_OPEN, 0);
|
||||||
|
@ -303,9 +305,7 @@ UBYTE FcbGetFileSize(xfcb FAR * lpXfcb)
|
||||||
fsize = SftGetFsize(sft_idx);
|
fsize = SftGetFsize(sft_idx);
|
||||||
|
|
||||||
/* compute the size and update the fcb */
|
/* compute the size and update the fcb */
|
||||||
lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz;
|
lpFcb->fcb_rndm = (fsize + (recsiz - 1)) / recsiz;
|
||||||
if ((fsize % lpFcb->fcb_recsiz) != 0)
|
|
||||||
++lpFcb->fcb_rndm;
|
|
||||||
|
|
||||||
/* close the file and leave */
|
/* close the file and leave */
|
||||||
if ((CritErrCode = -DosCloseSft(sft_idx, FALSE)) == SUCCESS)
|
if ((CritErrCode = -DosCloseSft(sft_idx, FALSE)) == SUCCESS)
|
||||||
|
|
Loading…
Reference in New Issue