开发者

Does LabWindows/CVI have something similar to _setmode() for setting the file (or stream) translation mode to binary or text?

I am using gSoap to generate ANSI C source code, that I would like to build within the LabWindows/CVI environment, on a Windows 7, 64 bit OS. The gSoap file stdsoap2.c includes several instances of the _setmode() function, with the following prototype:

int _setmode (int fd, int mode);

Where fd is a file descriptor, and mode is set to either _O_TEXT or _O_BINARY.

Oddly enough, even though LW/CVI contains an interface to Microsoft's SDK, this SDK does not contain a prototype to _setmode in any of its included header files, even though the help link to the SDK contains information on the function.

Is anyone aware 开发者_JAVA技巧of the method in LabWindows/CVI used to set file (or stream) translation mode to text, or binary.

Thanks, Ryyker


Closing the loop on this question.
I could not use the only offered answer for the reason listed in my comment above.
Although I did use the SDK, it was not to select a different version of the OpenFile function, rather it was to support the use of a function that an auto-code generator used, _setmode() but that was not supported by my primary development environment (LabWindows/CVI).

So, in summary, my solution WAS to include the SDK to give me definition for _setmode as well as including the following in my non- auto-generated code:

#define _O_TEXT         0x4000  /* file mode is text (translated) */     
#define _O_BINARY       0x8000  /* file mode is binary (untranslated) */

So, with the caveat that this post describes what I actually did, I am going to mark the answer @gary offered as the answer, as it was in the ball park. Thanks @gary.


It sounds like you just want to open a file as either ASCII or binary. So you should be able to replace the instances of _setmode() with the LW/CVI OpenFile() function as described here. Here's a short example reading a file as binary.

char filename = "path//to//file.ext"
int result;
result = OpenFile(filename, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_BINARY); 

if (result < 0)
    // Error, notify user.
else
    // No error.

Also note this warning from the page:

Caution The Windows SDK also contains an OpenFile function. If you include windows.h and do not include formatio.h, you will get compile errors if you call OpenFile.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜