Re: 64 bit integers (accessing files > 4Gb)
CChris wrote:
>
> Chris Bensler wrote:
> >
> > How do I access file data > 4Gb?
> >
> > The Windows API has SetFilePointerEx() but it requires large integers.
> > Is it possible to deal with large ints in Eu using atoms?
> >
>
> I didn't test this, but....
>
> In the wrapper for your routine, replace the large_integer by a C_LONG and
> a C_ULONG. Then, pass the high dword in the C_LONG and the low dword in the
>
> C_LONG, both using atoms as usual. This results in
>
> }}}
<eucode>
> constant kernel32=open_dll("kernel32.dll"),
> sfpx=define_c_func(kernel32,"SetFilePointerEx",
> {C_POINTER,C_LONG,C_ULONG,C_POINTER,C_ULONG},C_BOOL)
> </eucode>
{{{
>
> You'd pass 5 atoms to c_func() when calling the function. You'd also
> poke4() 2 atoms at the place pointed to by the 4th arg, which is the
> lpNewFilePointer parameter.
>
> If the large integer is pushed on the stack, which I expect on 32 bit
> machines, this hack should work, since it generates the stack layout the
> routine expects. Perhaps using a "+" to force a _cdecl call is safer.
> Again, I haven't tested this...
No, definitely do *not* use cdecl for calling the Win32 API. Otherwise,
your directions are correct. I've used these functions before, and you
can simply break up the LARGE_INTEGER into two 32-bit integers. You
just have to 'manually' do the 64-bit math and increment the high
dword yourself.
Matt
|
Not Categorized, Please Help
|
|