Message-ID: <33491C45.25D9@post.comstar.ru> Date: Mon, 07 Apr 1997 09:09:41 -0700 From: Dim Zegebart Reply-To: zager AT post DOT comstar DOT ru Organization: zager AT post DOT comstar DOT ru MIME-Version: 1.0 To: DJGPP Mail List Subject: Re: I/O References: <33433F4B DOT 7E2B AT postoffice DOT worldnet DOT att DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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