~ubuntu-branches/ubuntu/raring/binkd/raring-proposed

« back to all changes in this revision

Viewing changes to dos/getfree.c

  • Committer: Bazaar Package Importer
  • Author(s): Marco d'Itri
  • Date: 2002-03-24 22:52:25 UTC
  • Revision ID: james.westby@ubuntu.com-20020324225225-7ru6itlapn03nl35
Tags: upstream-0.9.5a
ImportĀ upstreamĀ versionĀ 0.9.5a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef __WATCOMC__
 
2
  #define __IBMC__ 0
 
3
  #define __IBMCPP__ 0
 
4
#endif
 
5
 
 
6
#include <dos.h>
 
7
#include <ctype.h>
 
8
#include <limits.h>
 
9
 
 
10
extern void Log (int lev, char *s,...);
 
11
 
 
12
unsigned long getfree (char *path)
 
13
{
 
14
  struct diskfree_t fsa;
 
15
  unsigned disknum = 0;
 
16
  int rc;
 
17
 
 
18
  if (isalpha (path[0]) && path[1] == ':')
 
19
    disknum = toupper (path[0]) - 'A' + 1;
 
20
 
 
21
  rc=_dos_getdiskfree(disknum,&fsa);
 
22
 
 
23
  if (rc)
 
24
  {
 
25
    Log (1, "_dos_gwtdiskfree error: return code = %u", rc);
 
26
    return ULONG_MAX;                       /* Assume enough disk space */
 
27
  }
 
28
  else
 
29
  {
 
30
    if (fsa.sectors_per_cluster * fsa.bytes_per_sector >= 1024)
 
31
      return (unsigned long)fsa.avail_clusters * (fsa.sectors_per_cluster * fsa.bytes_per_sector / 1024);
 
32
    else
 
33
      return (unsigned long)fsa.avail_clusters / (1024 / (fsa.sectors_per_cluster * fsa.bytes_per_sector));
 
34
  }
 
35
}