• ReadFile - how to detect EOF ?

    From R.Wieser@21:1/5 to All on Sun May 16 18:25:25 2021
    Hello all,

    I'm reading a file synchronously and non-overlapped using ReadFile. I'm
    also reading the file blockwise, and do not want to deal with an empty block when the filesize turns out to be an exact multiple of the blocksize (every block must contain data).

    IOW, how do I detect the EOF /without/ trying to use ReadFile and getting
    zero bytes back.

    I've tried a ReadFile of zero bytes, but that doesn't quite work. :-\

    I can ofcourse get and store the filesize beforehand and for each block subtract the ammount of bytes read, but that means I have duplicate data :
    a file that ends and a counter that /should/ than be zero. Which I would rather not have.

    I've ofcourse already DDGed the intarwebz for a hint, but have had not luck.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Astor@21:1/5 to All on Sat May 29 17:53:19 2021
    You can see MSDN : https://docs.microsoft.com/en-us/windows/win32/fileio/testing-for-the-end-of-a-file


    R.Wieser a écrit :
    Hello all,

    I'm reading a file synchronously and non-overlapped using ReadFile. I'm
    also reading the file blockwise, and do not want to deal with an empty block when the filesize turns out to be an exact multiple of the blocksize (every block must contain data).

    IOW, how do I detect the EOF /without/ trying to use ReadFile and getting zero bytes back.

    I've tried a ReadFile of zero bytes, but that doesn't quite work. :-\

    I can ofcourse get and store the filesize beforehand and for each block subtract the ammount of bytes read, but that means I have duplicate data :
    a file that ends and a counter that /should/ than be zero. Which I would rather not have.

    I've ofcourse already DDGed the intarwebz for a hint, but have had not luck.

    Regards,
    Rudy Wieser



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sat May 29 18:20:55 2021
    Christian,

    You can see MSDN : https://docs.microsoft.com/en-us/windows/win32/fileio/testing-for-the-end-of-a-file

    Yeah, I found that too. The problem with it is that you *have to read data*
    to be able to detect there isn't any more of it.

    IOW, if I want to mark the current full block of data as the last one I must have already read (some of) the next block able to determine the EOF status. And thats something I'd rather not do.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From holyghost@21:1/5 to R.Wieser on Fri Sep 24 05:46:35 2021
    On 5/29/2021 6:20 PM, R.Wieser wrote:
    Christian,

    You can see MSDN :
    https://docs.microsoft.com/en-us/windows/win32/fileio/testing-for-the-end-of-a-file

    Yeah, I found that too. The problem with it is that you *have to read data* to be able to detect there isn't any more of it.

    IOW, if I want to mark the current full block of data as the last one I must have already read (some of) the next block able to determine the EOF status. And thats something I'd rather not do.

    Regards,
    Rudy Wieser



    Maybe use streams and the "<<", ">>" operators. Then by reading your
    previous posts buy K&R (ANSI C) and Strousstrup (The C++ programming
    language) books. It will help you a lot.

    holly

    --
    (__)
    oo )
    |_/\

    My Software & Art company (donations are welcome) : https://ko-fi.com/brandywine9

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Fri Sep 24 11:21:08 2021
    holyghost,

    Maybe use streams and the "<<", ">>" operators.

    Alas, I'm not using C{something}to program in.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)