News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

HLA file functions vs Windows file functions

Started by V Coder, January 13, 2006, 03:27:46 AM

Previous topic - Next topic

V Coder

Is there any problem with opening a file using Windows createfile, and writing it using HLA fileio.put?

Is the handle returned by HLA the same as that reurned by Windows?

Thanks.

Sevag.K

It's the same handle, so if you created the file with the proper access rights, you can use the fileio.xxx functions on it.
Tthe only thing you'll lose is portability.

V Coder

Thanks.

Now do the HLA fileio. calls do delayed writes? I'm having a problem with my program. I run the save routine twice successively to save the same data (sometimes > 20 MB twice using different file names. The second file is always truncated severely at varying lengths. I'm wondering if it is because the write is delayed so that when the thread sending it closes, the data is lost. (The main program is still running.)

Sevag.K

Quote from: V Coder on January 13, 2006, 02:27:47 PM
Thanks.

Now do the HLA fileio. calls do delayed writes? I'm having a problem with my program. I run the save routine twice successively to save the same data (sometimes > 20 MB twice using different file names. The second file is always truncated severely at varying lengths. I'm wondering if it is because the write is delayed so that when the thread sending it closes, the data is lost. (The main program is still running.)

I don't think the standard library is thread safe.  You might want to look into co-routines for which I can't help you since I haven't made use of them.

Otherwise, if you are coding Windows specific, take a look at WriteFileEx function.  This routine signals when the write is complete by calling an address you supply.  With this information, you can terminate the thread only when the write is complete.



V Coder

I had thought that FlushFileBuffers, followed by CloseFile would do the trick. But it does not. The Save routine exits, and if the program closes, or processor intensive processing continues, all data is lost.

WriteFileEx looks like too much trouble.