source: buchla-68k/orig/IOLIB/FSIZE.C@ 6888aa2

Last change on this file since 6888aa2 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 1.7 KB
RevLine 
[3ae31e9]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 "stdio.h"
9#include "biosdefs.h"
10#include "io.h"
11#include "stddefs.h"
12
13extern short _gtcl12(), _opnvol(), _filecl();
14
15extern unsigned _thefat[];
16
17extern struct bpb *_thebpb;
18
19/*
20 =============================================================================
21 fsize() -- return the current size of an open stream file
22
23 how = 0: in bytes, 1: in allocated clusters
24 =============================================================================
25*/
26
27long
28fsize(fp, how)
29FILE *fp;
30short how;
31{
32 register struct channel *chp;
33 register struct fcb *fcp;
34
35 if (fp EQ (FILE *)0L)
36 return(-1L);
37
38 if (fp->_flags & _BUSY) {
39
40 chp = &chantab[fp->_unit];
41
42 if (chp->c_close NE _filecl)
43 return(-1L);
44
45 fcp = chp->c_arg;
46
47 if (fcp->modefl & FC_OPN) {
48
49 if (how)
50 return(fcp->asects);
51 else
52 return(fcp->curlen);
53
54 } else
55 return(-1L);
56
57 } else
58 return(-1L);
59}
60
61/*
62
63*/
64
65/*
66 =============================================================================
67 dspace() -- return disk capacity or usage
68
69 which = 0: capcity, 1: usage
70 =============================================================================
71*/
72
73short
74dspace(which)
75short which;
76{
77 register short maxcl, clcount, nc;
78
79 if (_opnvol())
80 return(-1L);
81
82 maxcl = _thebpb->numcl;
83
84 if (which) {
85
86 clcount = 0;
87
88 for (nc = 2; nc < maxcl; nc++)
89 if (0 EQ _gtcl12(_thefat, nc))
90 ++clcount;
91
92 return(clcount);
93
94 } else {
95
96 return(maxcl);
97 }
98}
Note: See TracBrowser for help on using the repository browser.