home *** CD-ROM | disk | FTP | other *** search
-
- MRARPFile - Extended ARP File Support
- Mark Rinfret, 10/89
- Public Domain
-
- This package constitutes a non-approved (at this time) extension to the ARP
- (Amiga Resource Project) programmer's support library. It is intended to
- be used with ARP version 1.3 and higher.
-
- I like ARP. I would like all of my utilities to take advantage of its
- shared library and resource tracking. While attempting to convert a
- program which appeared on the net not long ago, I realized that it would
- have been nice, had ARP provided the FGets/FPuts routines. Sure, you can
- simulate FPuts with FPrintf, but that's kludgy. You're still left hanging
- in the breeze when it comes to FGets. So, I started writing...
-
- As usually happens, the tail started shaking the dog. I spent all my free
- time this weekend cooking up this package and the original goal has yet to
- be completed. Hopefully, you'll find the effort worth it.
-
- This package provides an orthogonal set of routines which support
- generalized I/O with resource tracking (and early release, if you want)
- while using the ARP library. There are essentially 3 tracked objects
- associated with a file:
-
- - a structure describing the file
- - the file itself
- - an optional buffer
-
- Access to files is gained via the OpenARPFile function. A companion
- routine, CloseARPFile, will release all resources associated with the file.
- You need not call it, however, as ARP will release any as yet unreleased
- objects when the ARP library is closed.
-
- File buffering is optional, and recommended when using the FGetsARP and
- FPutsARP routines (typically used with text files). A SeekARPFile routine
- allows you some freedom of access, in both input and output files, properly
- managing the optional buffers.
-
- While implementing these routines, I ran into a strange problem with the
- "LastTracker" method (actually a call to IoErr()). Randomly, it seems, I
- would get a -1L rather than a valid "struct DefaultTracker" pointer.
- However, it seems that register A1 always contains the correct value.
- Therefore, I wrote a little assembly language function which will retrieve
- A1 for you. In order for it to be effective, it *MUST* be called
- immediately after calling an ARP routine which allocates a tracked
- resource. Example:
-
- myBuffer = ArpAllocMem(8192L, MEMF_PUBLIC|MEMF_CLEAR);
- myTracker = StoreTracker();
- if ( ! myBuffer ) {
- ...Buffer not allocated? myTracker is invalid, then...
- }
-
- Please see the embedded documentation in the source for more usage info. I
- feel this is just another of those little hacks that anyone could have
- done, but I needed it and thus appointed myself to do it. I hope some of
- you out there find it useful. I'd appreciate hearing any constructive
- comments that you might have.
-
- Mark Rinfret
-
- mrr@amanpt1.Newport.RI.US
- BIX: markr
-