From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: I/O Date: Sat, 5 Apr 1997 19:37:02 +0100 Organization: None Distribution: world Message-ID: References: <33433F4B DOT 7E2B AT postoffice DOT worldnet DOT att DOT net> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 29 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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... -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ Beauty is a French phonetic corruption of a short cloth neck ornament.