source: buchla-68k/libcio/fsize.c@ 6099cac

Last change on this file since 6099cac 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
RevLine 
[f40a309]1/*
2 =============================================================================
3 fsize.c -- file size and disk capacity functions
4 Version 1 -- 1987-10-29 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
[b28a12e]8#include "ram.h"
[f40a309]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
[7258c6a]18int32_t fsize(FILE *fp, int16_t how)
[f40a309]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
[7258c6a]57int16_t dspace(int16_t which)
[f40a309]58{
[7258c6a]59 register int16_t maxcl, clcount, nc;
[f40a309]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}
[6262b5c]81
Note: See TracBrowser for help on using the repository browser.