LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Correct way to close a file reference where fdopen() was use after OpenFile() initiated the file

I just wanted to verify that fclose() is the proper way to clean up resources as opposed to CloseFile().

 

The documentation kind of leaves the correct protocol up in the air.

 

Greg

0 Kudos
Message 1 of 4
(2,743 Views)

If I understand correctly, you are trying to open a file with OpenFile, translate the handle with fdopen and then write/read to/from it with standard C functions. Am I right?

Just out of curiosity, why are you using such a complicated pathway? Couldn't you simply use fopen instead?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(2,722 Views)

File format consist of text for the header with a single key stored per line (<1000 lines) followed by one or more data chunks of 32Msample or greater as binary int16 or real32 as detailed in the header.

 

I find it easiest to use ReadLine and WriteLine for the header and speediest to use ANSI C read / write for the chunked data.

 

fclose after fdopen seems to clean up any noticeable overhead.

 

 

Message 3 of 4
(2,701 Views)

Ok, thank you. Today I learned something new Smiley Happy



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(2,696 Views)