1pack_fopen(3)                   Allegro manual                   pack_fopen(3)
2
3
4

NAME

6       pack_fopen  -  Opens a file according to mode. Allegro game programming
7       library.
8

SYNOPSIS

10       #include <allegro.h>
11
12
13       PACKFILE *pack_fopen(const char *filename, const char *mode);
14

DESCRIPTION

16       Opens a file according to mode, which may contain any of the flags:
17
18       `r' - open file for reading.
19
20       `w' - open file for writing, overwriting any existing data.
21
22       `p' - open file in packed mode. Data will be compressed as it is  writ‐
23       ten to the file, and automatically uncompressed during read operations.
24       Files created in this mode will produce garbage if they are read  with‐
25       out this flag being set.
26
27       `!' - open file for writing in normal, unpacked mode, but add the value
28       F_NOPACK_MAGIC to the start of the file, so that it can later be opened
29       in packed mode and Allegro will automatically detect that the data does
30       not need to be decompressed.
31
32       Instead  of  these  flags,  one  of  the  constants  F_READ,   F_WRITE,
33       F_READ_PACKED, F_WRITE_PACKED or F_WRITE_NOPACK may be used as the mode
34       parameter.
35
36       The packfile functions also understand several "magic"  filenames  that
37       are used for special purposes. These are:
38
39       `#' - read data that has been appended to your executable file with the
40       exedat utility, as if it was a regular independent disk file.
41
42       `filename.dat#object_name' - open a specific object  from  a  datafile,
43       and  read  from  it  as  if it was a regular file. You can treat nested
44       datafiles exactly like a normal directory structure,  for  example  you
45       could open `filename.dat#graphics/level1/mapdata'.
46
47       `#object_name'  -  combination  of  the above, reading an object from a
48       datafile that has been appended onto your executable.
49
50       With these special filenames, the contents  of  a  datafile  object  or
51       appended file can be read in an identical way to a normal disk file, so
52       any of the  file  access  functions  in  Allegro  (eg.  load_pcx()  and
53       set_config_file())  can  be used to read from them. Note that you can't
54       write to these special files, though: the fake file is read only. Also,
55       you must save your datafile uncompressed or with per-object compression
56       if you are planning on loading individual objects  from  it  (otherwise
57       there will be an excessive amount of seeking when it is read).
58
59       Finally, be aware that the special Allegro object types aren't the same
60       format as the files you import the data from. When you import data like
61       bitmaps  or samples into the grabber, they are converted into a special
62       Allegro-specific format, but the  `#'  marker  file  syntax  reads  the
63       objects as raw binary chunks. This means that if, for example, you want
64       to use load_pcx() to read an image from a datafile, you  should  import
65       it as a binary block rather than as a BITMAP object.
66
67       Example:
68
69          PACKFILE *input_file;
70
71          input_file = pack_fopen("scores.dat", "rp");
72          if (!input_file)
73             abort_on_error("Couldn't read `scores.dat'!");
74

RETURN VALUE

76       On success, pack_fopen() returns a pointer to a PACKFILE structure, and
77       on error it returns NULL and  stores  an  error  code  in  `errno'.  An
78       attempt  to  read a normal file in packed mode will cause `errno' to be
79       set to EDOM.
80
81

SEE ALSO

83       pack_fclose(3),       pack_fopen_chunk(3),        packfile_password(3),
84       pack_fread(3),  pack_getc(3),  file_select_ex(3), pack_fopen_vtable(3),
85       expackf(3)
86
87
88
89Allegro                          version 4.2.2                   pack_fopen(3)
Impressum