.\" Automatically generated by Pandoc 3.1.11.1 .\" .TH "al_fopen" "3" "" "Allegro reference manual" "" .SH NAME al_fopen \- Allegro 5 API .SH SYNOPSIS .IP .EX #include ALLEGRO_FILE *al_fopen(const char *path, const char *mode) .EE .SH DESCRIPTION Creates and opens a file (real or virtual) given the path and mode. The current file interface is used to open the file. .PP Parameters: .IP \[bu] 2 path \- path to the file to open .IP \[bu] 2 mode \- access mode to open the file in (\[lq]r\[rq], \[lq]w\[rq], etc.) .PP Depending on the stream type and the mode string, files may be opened in \[lq]text\[rq] mode. The handling of newlines is particularly important. For example, using the default stdio\-based streams on DOS and Windows platforms, where the native end\-of\-line terminators are CR+LF sequences, a call to al_fgetc(3) may return just one character (`\[rs]n') where there were two bytes (CR+LF) in the file. When writing out `\[rs]n', two bytes would be written instead. (As an aside, `\[rs]n' is not defined to be equal to LF either.) .PP Newline translations can be useful for text files but is disastrous for binary files. To avoid this behaviour you need to open file streams in binary mode by using a mode argument containing a \[lq]b\[rq], e.g.\ \[lq]rb\[rq], \[lq]wb\[rq]. .PP Returns a file handle on success, or NULL on error. .SH SEE ALSO al_set_new_file_interface(3), al_fclose(3).