The MASM Forum Archive 2004 to 2012

Project Support Forums => HLA Forum => Topic started by: V Coder on January 13, 2006, 03:27:46 AM

Title: HLA file functions vs Windows file functions
Post by: V Coder on January 13, 2006, 03:27:46 AM
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.
Title: Re: HLA file functions vs Windows file functions
Post by: Sevag.K on January 13, 2006, 04:52:31 AM
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.
Title: Re: HLA file functions vs Windows file functions
Post by: 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.)
Title: Re: HLA file functions vs Windows file functions
Post by: Sevag.K on January 14, 2006, 03:31:39 AM
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.


Title: Re: HLA file functions vs Windows file functions
Post by: V Coder on February 05, 2006, 05:56:01 AM
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.