コード例 #1
0
ファイル: isramdsk.c プロジェクト: Eric-Schnipke/snippets
Boolean_T isRamDsk(unsigned char drive)
{
      union REGS regs;
      B_REC buffer;

      regs.x.ax = 0x4408;           /* Not if removable     */
      regs.h.bl = (unsigned)toupper(drive) - (unsigned char)'@';
      intdos(&regs, &regs);
      if (0 == regs.x.ax)
            return False_;
      if (AbsDiskRead(toupper(drive) - 'A', 1, 0, &buffer))
            return Error_;
      return (1 == buffer.bsFATs);
} 
コード例 #2
0
ファイル: cacheabs.c プロジェクト: JFLarvoire/SysToolsLib
int _cdecl CachedAbsDiskRead(int iDrive, DWORD dwSector, WORD wOffset,
			WORD wLength, void *pBuf)
    {
    int err;
    DEVICEPARAMS dpCache;
    DEVICEPARAMS *pdp = &dpCache;
    WORD wToCopy;

    if (iDrive != iCachedDrive)
	{
	if (iCacheDirty) CachedAbsDiskFlush();
	iCachedDrive = -1;  /* Assume failure reading the drive parameters */
	err = GetDeviceParams(iDrive, pdp);
	if (err) return err;			    /* Access denied */
	if (pdp->dpBytesPerSec > 1024) return 5;    /* Prevent cache overflow */
	wCachedSectorSize = pdp->dpBytesPerSec;
	iCachedDrive = iDrive;	 /* Flag success: Drive parameters are valid. */
	dwCachedSector = NO_SECTOR;	  // Force reading the new drive
	}

    /* Prevent errors */
    if (wOffset >= wCachedSectorSize) return 5;

    while (wLength)
	{
	if (dwSector != dwCachedSector)   // Don't read twice the same sector
	    {
	    if (iCacheDirty) CachedAbsDiskFlush();
	    err = AbsDiskRead(iDrive, dwSector, 1, cSectorCache);
	    if (err) return err;
	    dwCachedSector = dwSector;
	    }

	wToCopy = min(wLength, wCachedSectorSize - wOffset);
	memcpy(pBuf, cSectorCache+wOffset, wToCopy);

	dwSector += 1;
	wOffset = 0;
	wLength -= wToCopy;
	(char *)pBuf += wToCopy;
	}

    return 0;
    }