| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflfile.h" FILE * file_open ( const char *filename, /* Name of file to open */ char mode) /* 'r', 'w', or 'a' */
opens a text file for reading or writing. Use in combination with the file read() and file write() functions. These functions handle end-of-line sequences using a heuristic that works as follows. ... (at this point the author went for a pint of beer and has not been seen since. We're hoping that the old version - following - is ok.)Opens the specified file for input or output. If you use the file_read / file_write functions you must open the file using this function. This set of functions lets you read files without concern for the line format (CRLF or LF). Mode should be one of 'r' 'w' 'a'. Returns a FILE pointer if the file is opened correctly; else NULL. Sets the global variable file_crlf to FALSE on all systems except MS-DOS (and Windows by inheritence) where it is set to TRUE by default. When opening a file in append mode, automatically removes any Ctrl-Z character under MS-DOS or OS/2.
{ #if (defined (MSDOS_FILESYSTEM)) if (system_devicename (filename)) return (NULL); /* Not allowed on device names */ file_crlf = TRUE; # if (defined (WIN32)) SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); # endif # else ASSERT (filename); file_crlf = FALSE; #endif if (mode == 'r') return (fopen (filename, FOPEN_READ_BINARY)); else if (mode == 'w') return (fopen (filename, FOPEN_WRITE_BINARY)); else if (mode == 'a' && safe to extend (filename)) return (fopen (filename, FOPEN_APPEND_BINARY)); else return (NULL); /* Invalid mode */ }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |