IsoFileInfoPointer->FileStart = Record->ExtentLocationL;
IsoFileInfoPointer->FileSize = Record->DataLengthL;
IsoFileInfoPointer->FilePointer = 0;
- IsoFileInfoPointer->Directory = (Record->FileFlags & 0x02)?TRUE:FALSE;
+ IsoFileInfoPointer->Directory = !!(Record->FileFlags & 0x02);
return TRUE;
}
ARC_STATUS IsoRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
{
+ ARC_STATUS Status;
PISO_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId);
UCHAR SectorBuffer[SECTORSIZE];
LARGE_INTEGER Position;
ULONG DeviceId;
- ULONG FilePointer;
- ULONG SectorNumber;
- ULONG OffsetInSector;
- ULONG LengthInSector;
- ULONG NumberOfSectors;
+ ULONG SectorNumber;
+ ULONG OffsetInSector;
+ ULONG LengthInSector;
+ ULONG NumberOfSectors;
ULONG BytesRead;
- ARC_STATUS Status;
TRACE("IsoRead() Buffer = %p, N = %lu\n", Buffer, N);
*Count = 0;
//
- // If they are trying to read past the
- // end of the file then return success
- // with Count == 0
+ // If the user is trying to read past the end of
+ // the file then return success with Count == 0.
//
- FilePointer = FileHandle->FilePointer;
- if (FilePointer >= FileHandle->FileSize)
+ if (FileHandle->FilePointer >= FileHandle->FileSize)
{
return ESUCCESS;
}
//
- // If they are trying to read more than there is to read
- // then adjust the amount to read
+ // If the user is trying to read more than there is to read
+ // then adjust the amount to read.
//
- if (FilePointer + N > FileHandle->FileSize)
+ if (FileHandle->FilePointer + N > FileHandle->FileSize)
{
- N = FileHandle->FileSize - FilePointer;
+ N = FileHandle->FileSize - FileHandle->FilePointer;
}
//
// Only do the first read if we
// aren't aligned on a cluster boundary
//
- if (FilePointer % SECTORSIZE)
+ if (FileHandle->FilePointer % SECTORSIZE)
{
//
// Do the math for our first read
//
- SectorNumber = FileHandle->FileStart + (FilePointer / SECTORSIZE);
- OffsetInSector = FilePointer % SECTORSIZE;
- LengthInSector = (N > (SECTORSIZE - OffsetInSector)) ? (SECTORSIZE - OffsetInSector) : N;
+ SectorNumber = FileHandle->FileStart + (FileHandle->FilePointer / SECTORSIZE);
+ OffsetInSector = FileHandle->FilePointer % SECTORSIZE;
+ LengthInSector = min(N, SECTORSIZE - OffsetInSector);
//
// Now do the read and update Count, N, FilePointer, & Buffer
RtlCopyMemory(Buffer, SectorBuffer + OffsetInSector, LengthInSector);
*Count += LengthInSector;
N -= LengthInSector;
- FilePointer += LengthInSector;
+ FileHandle->FilePointer += LengthInSector;
Buffer = (PVOID)((ULONG_PTR)Buffer + LengthInSector);
}
//
NumberOfSectors = (N / SECTORSIZE);
- SectorNumber = FileHandle->FileStart + (FilePointer / SECTORSIZE);
+ SectorNumber = FileHandle->FileStart + (FileHandle->FilePointer / SECTORSIZE);
//
// Now do the read and update Count, N, FilePointer, & Buffer
*Count += NumberOfSectors * SECTORSIZE;
N -= NumberOfSectors * SECTORSIZE;
- FilePointer += NumberOfSectors * SECTORSIZE;
+ FileHandle->FilePointer += NumberOfSectors * SECTORSIZE;
Buffer = (PVOID)((ULONG_PTR)Buffer + NumberOfSectors * SECTORSIZE);
}
//
if (N > 0)
{
- SectorNumber = FileHandle->FileStart + (FilePointer / SECTORSIZE);
+ SectorNumber = FileHandle->FileStart + (FileHandle->FilePointer / SECTORSIZE);
//
// Now do the read and update Count, N, FilePointer, & Buffer
}
RtlCopyMemory(Buffer, SectorBuffer, N);
*Count += N;
- FilePointer += N;
+ FileHandle->FilePointer += N;
}
TRACE("IsoRead() done\n");