Chris
2008-01-23 17:42:22 UTC
Hi,
I use this function which I have from MSDN, to handle file pointers in large
file sizes.
__int64 FilePosition (HANDLE hf, __int64 distance, DWORD MoveMethod)
{
LARGE_INTEGER li;
li.QuadPart = distance;
li.LowPart = SetFilePointer (hf, li.LowPart, \
&li.HighPart, MoveMethod);
if (li.LowPart == INVALID_SET_FILE_POINTER && \
GetLastError() != NO_ERROR)
{
li.QuadPart = -1;
}
return li.QuadPart;
}
My function uses it to occasionally set the file pointer back.
__int64 pos;
if ((pos = FilePosition(bitfile, 0L , FILE_CURRENT)) == -1)
{
printf("Unable to get file position.");
exit(1);
}
ReadFile(bitfile, &tmp, sizeof(unsigned char)*4, &nbytes, 0 );
/* checking some things */
if ((FilePosition(bitfile, pos, FILE_BEGIN)) == -1);
{
printf("Unable to set file position.");
exit(1);
}
Getting the file position and reading goes fine, I checked this for the
adresses,
but setting the pointer back consequently fails and comes up with the
"unable to set file position" error.
My source is C++ and runs from a thread in a dll. All additional reading
and writing goes fine except this little function.
Have someone any idea?
Thanks,
Chris.
I use this function which I have from MSDN, to handle file pointers in large
file sizes.
__int64 FilePosition (HANDLE hf, __int64 distance, DWORD MoveMethod)
{
LARGE_INTEGER li;
li.QuadPart = distance;
li.LowPart = SetFilePointer (hf, li.LowPart, \
&li.HighPart, MoveMethod);
if (li.LowPart == INVALID_SET_FILE_POINTER && \
GetLastError() != NO_ERROR)
{
li.QuadPart = -1;
}
return li.QuadPart;
}
My function uses it to occasionally set the file pointer back.
__int64 pos;
if ((pos = FilePosition(bitfile, 0L , FILE_CURRENT)) == -1)
{
printf("Unable to get file position.");
exit(1);
}
ReadFile(bitfile, &tmp, sizeof(unsigned char)*4, &nbytes, 0 );
/* checking some things */
if ((FilePosition(bitfile, pos, FILE_BEGIN)) == -1);
{
printf("Unable to set file position.");
exit(1);
}
Getting the file position and reading goes fine, I checked this for the
adresses,
but setting the pointer back consequently fails and comes up with the
"unable to set file position" error.
My source is C++ and runs from a thread in a dll. All additional reading
and writing goes fine except this little function.
Have someone any idea?
Thanks,
Chris.