source: buchla-68k/libcio/fsize.c

Last change on this file was fa38804, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Removed form-feed comments.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 =============================================================================
3 fsize.c -- file size and disk capacity functions
4 Version 1 -- 1987-10-29 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "ram.h"
9
10/*
11 =============================================================================
12 fsize() -- return the current size of an open stream file
13
14 how = 0: in bytes, 1: in allocated clusters
15 =============================================================================
16*/
17
18int32_t fsize(FILE *fp, int16_t how)
19{
20 register struct channel *chp;
21 register struct fcb *fcp;
22
23 if (fp EQ (FILE *)0L)
24 return(-1L);
25
26 if (fp->_flags & _BUSY) {
27
28 chp = &chantab[fp->_unit];
29
30 if (chp->c_close NE _filecl)
31 return(-1L);
32
33 fcp = chp->c_arg;
34
35 if (fcp->modefl & FC_OPN) {
36
37 if (how)
38 return(fcp->asects);
39 else
40 return(fcp->curlen);
41
42 } else
43 return(-1L);
44
45 } else
46 return(-1L);
47}
48
49/*
50 =============================================================================
51 dspace() -- return disk capacity or usage
52
53 which = 0: capcity, 1: usage
54 =============================================================================
55*/
56
57int16_t dspace(int16_t which)
58{
59 register int16_t maxcl, clcount, nc;
60
61 if (_opnvol())
62 return(-1L);
63
64 maxcl = _thebpb->numcl;
65
66 if (which) {
67
68 clcount = 0;
69
70 for (nc = 2; nc < maxcl; nc++)
71 if (0 EQ _gtcl12(_thefat, nc))
72 ++clcount;
73
74 return(clcount);
75
76 } else {
77
78 return(maxcl);
79 }
80}
81
Note: See TracBrowser for help on using the repository browser.