al_fopen
ALLEGRO_FILE *al_fopen(const char *path, const char *mode)
Introduced in 5.0.0
Creates and opens a file (real or virtual) given the path and mode. The current file interface is used to open the file.
Parameters:
- path - path to the file to open
- mode - access mode to open the file in ("r", "w", etc.)
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 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, al_fclose.
Examples: ex_physfs
Most helpful discussions:
- Bug in allegro filestytem? I think that reads are drifting! (3)
- [A5] Writing Unicode to a file (1)
- linking on ubuntu
- al_load_font with PhysFS
- Filesystem access on android
- What's the easiest way to distribute my Allegro 5 game to buddies?
- Video playback issues
- Does al_load_bitmap_f work
- Allegro 5, android, writing files.
- text won't render in iOS build
Other recent discussions:
- Does PhysFS work for you with Allegro 5.2.2?
- Decrypting files in memory and reading them.
- al_fread problems on Windows
- Link conflict building Allegro
- al_fopen XCode
- Bitmap not loading again
- [A5] trouble writing ALLEGRO_BITMAP to zip file
- [A5] al_load_bitmap_f fails
- al_save_bitmap not working!
- [A5] al_filename_exists() can't see file.