TutFOpen


Name

TutFOpen — open a file in a platform-independent way

Synopsis

FILE *TutFOpen(file_name, file_mode) 
T_STR file_name; 
T_STR file_mode; 

Arguments

file_name — name of file to be opened

file_mode — mode to open file in

Return Values

FILE pointer of opened file. NULL if unable to open file_name using file_mode.

Diagnostics

If TutFOpen fails, it returns NULL and sets the global SmartSockets error number to one of these values:

Description

This function calls the C library function fopen using a standard set of arguments that opens a file in a "normal" way. This provides an operating system independent way to open a file. If called with the mode argument of "r", "w", or "a", then any necessary platform-specific arguments are added to make fopen behave with the expected UNIX semantics. On OpenVMS platforms, additional arguments are added to specify file sharing characteristics. The arguments expected for file_mode and their meanings are:

Any other value for file_mode causes the function fopen to be called with the specified argument.

Caution

Do not use this function to open a file with special arguments. If any special arguments are required, such as additional arguments that may be needed on OpenVMS, call fopen directly.

See Also

TutSetFileOpenFunc, TutSetFileCloseFunc, TutSetFileReadFunc

Examples

This example opens a file in write mode, truncating any previous contents of the file, and then writes one line of data into it:

FILE *file; 
 
file = TutFOpen("myfile.dat", "w"); 
if (file == NULL) { 
  /* error */ 
} 
 
fprintf(file, "%s", "This is a data file\n"); 
 
fclose(file); 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com