al_fopen_slice(3)
π NAME π
al_fopen_slice β Allegro 5 API, straight from the Library Functions Manual, bestie. We're opening a slice of a file like it's a whole separate file. Slay.
β¨ SYNOPSIS β¨
#include <allegro5/allegro.h>
ALLEGRO_FILE *al_fopen_slice(ALLEGRO_FILE *fp, size_t initial_size, const char *mode)
π¦ DESCRIPTION π¦
Okay so picture this: al_fopen_slice opens a slice β a subset β of an already open random access file, and treats it like it's a stand-alone file. Iconic. But while the slice is open, the parent file handle must not be used in any way. Not even a little. Don't touch it, bestie. π
The slice opens at the current location of the parent file, up through initial_size bytes. The initial_size can be any non-negative integer that will not exceed the bounds of the parent file. No cap, except the actual parent file bounds, obviously. π
Seeking with ALLEGRO_SEEK_SET will be relative to this starting location. Seeking with ALLEGRO_SEEK_END will be relative to the starting location plus the size of the slice. Math but make it file I/O. β¨
The mode can be any combination of:
rβ read accesswβ write accesseβ expandablesβ seek to the end of the slice uponal_close(3)(this is the default behavior)nβ disable the seeking behavior of βsβ
For example, a mode of βrwβ indicates the file can be read and written. (Note that this is slightly different from the stdio modes.) Keep in mind that the parent file must support random access and be open in normal write mode (not append) for the slice to work in a well defined way. That part is important, don't skip it.
If the slice is marked as expandable, then reads and writes can happen after the initial end point, and the slice will grow accordingly. Otherwise, all activity is restricted to the initial size of the slice. No sneaky growth unless you asked for e, periodt.
A slice must be closed with al_fclose(3). The parent file will then be positioned immediately after the end of the slice. This behavior can be disabled by setting the βnβ mode. So yeah, close it properly or the vibes are off. π
πΈ SINCE πΈ
5.0.6, 5.1.0 β it's been around, bestie.
π SEE ALSO π
al_fopen(3)β go peek at that one too.
Later, bestie! π Source/version vibe: Allegro reference manual β page tag al_fopen_slice(3). No date on this footer, just pure Allegro reference manual energy. Mwah! π
π¦ where this page comes from
- arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms