al_fopen - Man Page

Allegro 5 API

Synopsis

#include <allegro5/allegro.h>

ALLEGRO_FILE *al_fopen(const char *path, const char *mode)

Description

Creates and opens a file (real or virtual) given the path and mode. The current file interface is used to open the file.

Parameters:

Depending on the stream type and the mode string, files may be opened in “text” 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 (`\n') where there were two bytes (CR+LF) in the file. When writing out `\n', two bytes would be written instead. (As an aside, `\n' is not defined to be equal to LF either.)

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 “b”, e.g. “rb”, “wb”.

Returns a file handle on success, or NULL on error.

See Also

al_set_new_file_interface(3), al_fclose(3).

Referenced By

al_android_set_apk_file_interface(3), al_create_file_handle(3), al_fgets(3), al_fget_ustr(3), al_fopen_fd(3), al_fopen_interface(3), al_fopen_slice(3), al_fputs(3), ALLEGRO_FILE_INTERFACE(3), al_open_fs_entry(3), al_set_new_file_interface(3), al_set_physfs_file_interface(3), al_set_standard_file_interface(3).

Allegro reference manual