return nReaded;
}
-// Postion file pointer in the file
+// Position file pointer in the file
static
cmsBool FileSeek(cmsIOHANDLER* iohandler, cmsUInt32Number offset)
{
{
cmsIOHANDLER* iohandler = NULL;
FILE* fm = NULL;
+ cmsInt32Number fileLen;
_cmsAssert(FileName != NULL);
_cmsAssert(AccessMode != NULL);
_cmsFree(ContextID, iohandler);
cmsSignalError(ContextID, cmsERROR_FILE, "File '%s' not found", FileName);
return NULL;
+ }
+ fileLen = cmsfilelength(fm);
+ if (fileLen < 0)
+ {
+ fclose(fm);
+ _cmsFree(ContextID, iohandler);
+ cmsSignalError(ContextID, cmsERROR_FILE, "Cannot get size of file '%s'", FileName);
+ return NULL;
}
- iohandler -> ReportedSize = (cmsUInt32Number) cmsfilelength(fm);
+
+ iohandler -> ReportedSize = (cmsUInt32Number) fileLen;
break;
case 'w':
cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* Stream)
{
cmsIOHANDLER* iohandler = NULL;
+ cmsInt32Number fileSize;
+
+ fileSize = cmsfilelength(Stream);
+ if (fileSize < 0)
+ {
+ cmsSignalError(ContextID, cmsERROR_FILE, "Cannot get size of stream");
+ return NULL;
+ }
iohandler = (cmsIOHANDLER*) _cmsMallocZero(ContextID, sizeof(cmsIOHANDLER));
if (iohandler == NULL) return NULL;
iohandler -> ContextID = ContextID;
iohandler -> stream = (void*) Stream;
iohandler -> UsedSpace = 0;
- iohandler -> ReportedSize = (cmsUInt32Number) cmsfilelength(Stream);
+ iohandler -> ReportedSize = (cmsUInt32Number) fileSize;
iohandler -> PhysicalFile[0] = 0;
iohandler ->Read = FileRead;
}
-// Check existance
+// Check existence
cmsBool CMSEXPORT cmsIsTag(cmsHPROFILE hProfile, cmsTagSignature sig)
{
_cmsICCPROFILE* Icc = (_cmsICCPROFILE*) (void*) hProfile;
return FALSE;
}
- // Adjust endianess of the used parameters
+ // Adjust endianness of the used parameters
Icc -> DeviceClass = (cmsProfileClassSignature) _cmsAdjustEndianess32(Header.deviceClass);
Icc -> ColorSpace = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Header.colorSpace);
Icc -> PCS = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Header.pcs);
memset(&Header.reserved, 0, sizeof(Header.reserved));
- // Set profile ID. Endianess is always big endian
+ // Set profile ID. Endianness is always big endian
memmove(&Header.profileID, &Icc ->ProfileID, 16);
// Dump the header
LocalTypeHandler.ICCVersion = Icc ->Version;
Icc -> TagPtrs[n] = LocalTypeHandler.ReadPtr(&LocalTypeHandler, io, &ElemCount, TagSize);
- // The tag type is supported, but something wrong happend and we cannot read the tag.
+ // The tag type is supported, but something wrong happened and we cannot read the tag.
// let know the user about this (although it is just a warning)
if (Icc -> TagPtrs[n] == NULL) {