home *** CD-ROM | disk | FTP | other *** search
- /*
- bfaux.c
-
- % extra block file functions
-
- OWL 1.2
- Copyright (c) 1989, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/09/89 jdc changed oslist_GetSym to oslist_Get
- 8/19/89 jdc fixed bfile_FindEnd
-
- 11/00/89 jdc added call to bfile_pad
- 1/20/89 jdc changed oslist stuff
- 2/03/90 jmd added casts
-
- 3/28/90 jmd ansi-fied
- 4/15/90 jdc added bfile_ReadOnly, preened
- 9/07/90 jmd renamed oslist stuff
- */
-
- #include "oakhead.h"
- #include "bfdecl.h"
-
- boolean bfile_FindEnd(bfile_type bfile, char *name, int type)
- /*
- sets the current file block chain for appending.
- if the chain doesn't exist then it is created.
- "type" is a label for possible reference use and is ignored by bfile code
- returns: TRUE or FALSE
- */
- {
- char headbuf[BHEAD_LEN + 1];
-
- if (!bfile_Find(bfile, name, type)) {
- return(FALSE);
- }
- bfile->new_find = FALSE;
-
- headbuf[(int)BHEAD_LEN] = '\0';
-
- while (bfile->curnext_block != BFILE_NOMORE) {
- /* go to next block */
- bfile->current_block = bfile->curnext_block;
- }
-
- bfrseek(bfile);
- fread(headbuf, 1, (int)BHEAD_LEN, bfile->stream);
- sscanf(headbuf, "%5d%5d\n", &(bfile->curblock_size), &(bfile->curnext_block));
-
- if (ferror(bfile->stream)) return(FALSE);
-
- bfile_pad(bfile);
-
- return(TRUE);
- }
-
- /* -------------------------------------------------------------------------- */
-
- void bfile_Del(bfile_type bfile, char *name)
- {
- int *data, h;
-
- if (bfile != NULL && (h = bfile_FindDirHandle(bfile, name)) != OSLIST_BADNAME) {
-
- data = (int *) bfile_GetDirData(bfile, h);
- bfile_PutFreeB(bfile, data[0]);
- oslist_Delete(bfile->dir, h);
-
- bfile_WriteDir(bfile);
- }
- }
-
-