The following function I have designed to read a value from a specified
position in a file, convert it from little endian to big endian, and then
return. It uses Host Control APIs.
Here are the first 16 bytes in the file: 6F 00 00 00   00 02 00 00   08 00
00 00   09 02 00 00
Very interestingly, position = 8, the HostFRead() function reads:
    00 02 00 00 (Palm OS Simulator /ROM 5.3)
    08 00 00 00 (Plam OS Emulator/ ROM 4.2)

Ques: Any idea why?

UInt32 Converter: ReadLongValue (HostFILE *hFile, Int32 position)
{
    UInt32  value;
    UInt32  numItems;

    if (HostFSetPos(hFile, &position) != 0) {
        ErrDisplay ("Converter::ReadLongValue(): HostFSetPos() failed!");
        return 0;
    }
    if ((numItems = HostFRead (&value, sizeof (UInt32), 1, hFile)) != 1) {
        ErrDisplay ("Converter::ReadLongValue(): HostFRead() failed!");
        return 0;
    }

    return (value << 24) | ((value & 0x0000FF00) << 8) |
           ((value & 0x00FF0000) >> 8) | (value >> 24);
}

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to