home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / BFAUX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-07  |  1.7 KB  |  76 lines

  1. /*
  2.     bfaux.c    
  3.  
  4.     % extra block file functions
  5.  
  6.     OWL 1.2
  7.     Copyright (c) 1989, by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.      8/09/89 jdc    changed oslist_GetSym to oslist_Get
  13.      8/19/89 jdc    fixed bfile_FindEnd
  14.  
  15.     11/00/89 jdc    added call to bfile_pad
  16.      1/20/89 jdc    changed oslist stuff
  17.      2/03/90 jmd    added casts
  18.  
  19.      3/28/90 jmd    ansi-fied
  20.      4/15/90 jdc    added bfile_ReadOnly, preened
  21.      9/07/90 jmd    renamed oslist stuff
  22. */
  23.  
  24. #include "oakhead.h"
  25. #include "bfdecl.h"
  26.  
  27. boolean bfile_FindEnd(bfile_type bfile, char *name, int type)
  28. /* 
  29.     sets the current file block chain for appending.
  30.     if the chain doesn't exist then it is created.
  31.     "type" is a label for possible reference use and is ignored by bfile code
  32.     returns:  TRUE or FALSE
  33. */
  34. {
  35.     char headbuf[BHEAD_LEN + 1];
  36.     
  37.     if (!bfile_Find(bfile, name, type)) {
  38.         return(FALSE);
  39.     }
  40.     bfile->new_find = FALSE;
  41.  
  42.     headbuf[(int)BHEAD_LEN] = '\0';
  43.  
  44.     while (bfile->curnext_block != BFILE_NOMORE) {
  45.         /* go to next block */
  46.         bfile->current_block = bfile->curnext_block;
  47.     }
  48.  
  49.     bfrseek(bfile);
  50.     fread(headbuf, 1, (int)BHEAD_LEN, bfile->stream);
  51.     sscanf(headbuf, "%5d%5d\n", &(bfile->curblock_size), &(bfile->curnext_block));
  52.  
  53.     if (ferror(bfile->stream)) return(FALSE);
  54.  
  55.     bfile_pad(bfile);
  56.  
  57.     return(TRUE);
  58. }
  59.  
  60. /* -------------------------------------------------------------------------- */
  61.  
  62. void bfile_Del(bfile_type bfile, char *name)
  63. {
  64.     int *data, h;
  65.  
  66.     if (bfile != NULL && (h = bfile_FindDirHandle(bfile, name)) != OSLIST_BADNAME) {
  67.  
  68.         data = (int *) bfile_GetDirData(bfile, h);
  69.         bfile_PutFreeB(bfile, data[0]);
  70.         oslist_Delete(bfile->dir, h);
  71.  
  72.         bfile_WriteDir(bfile);
  73.     }
  74. }
  75.  
  76.