Mail Archives: djgpp/1997/04/07/01:17:10
Shawn Hargreaves wrote:
>
> Patrick J. Morris writes:
> >I was just wondering if I could read and write to a text file that
> >is compressed in and Allegro Dat file. I want to be able to read and
> >write to the file without having any information lost.
>
> Modifying an Allegro datafile isn't such an easy operation: they were
> designed as a read-only format for bulky data, and writing them is very
> inefficient.
>
> Reading the file can be done either by importing it as a binary data
> object and examining the dat pointer after the datafile is loaded (it
> will just point to a binary copy of the text file), or by importing the
> data as some other object type (eg. TEXT), and using the
> register_datafile_object() to specify a custom load routine.
>
> If you really need to write the data as well, you can modify the
> contents of the datafile while it is held in memory and then use the
> functions from datedit.c (not part of the main library, but used by the
> grabber, dat.exe, and dat2s.exe), to write the modified data back to
> disk. That's a very clumsy and ugly way of modifying the data, though.
>
> If what you need is just the file compression, you can get that without
> using a datafile with the pack_fopen(), pack_fread(), etc, family of
> functions...
I'm not shure but it seems to me what another possible solution is
using GDBM. It's useful for large bin objects of various types.
--
Regards,
Dim Zegebart,
Moscow Russia.
Ghostly basement : http://www.geocities.com/siliconvalley/pines/7817
- Raw text -