Ejemplo n.º 1
0
cpm_word fcb_dfree (cpm_byte drive, cpm_byte *dma)
{
#ifdef WIN32
	LPDWORD spc, bps, fc, tc;
	unsigned int freerec;
	char *hostd = drive_to_hostdrive(drive);
	
	if (!hostd) return 0x01FF;
        if (!hostd) return 0x01FF;  /* Can't select */

	if (!GetDiskFreeSpace(hostd, spc, bps, fc, tc))
		return 0x01FF;	/* Can't select */

	freerec = *fc;		/* Free clusters */
	freerec *= *spc;		/* Free sectors */
	freerec *= (*bps / 128);	/* Free CP/M records */

	/* Limit to maximum CP/M drive size */
	if (freerec > 4194303L) freerec = 4194303L;
	redir_wr24(dma, freerec);
		
#else
	struct statfs buf;
	long dfree;

	if (!redir_drive_prefix[drive]) return 0x01FF;	/* Can't select */
	
	if (statfs(redir_drive_prefix[drive], &buf)) return 0x01FF;

	dfree = (buf.f_bavail * (buf.f_bsize / 128));

	if (dfree < buf.f_bavail ||	/* Calculation has wrapped round */
	    dfree > 4194303L)           /* Bigger than max CP/M drive size */
	{
		dfree = 4194303L;
	}

	redir_wr24(dma, dfree);
#endif
	return 0;
}
Ejemplo n.º 2
0
cpm_word fcb_dfree (cpm_byte drive, cpm_byte *dma)
{
#ifdef WIN32
        DWORD secclus, bps, freeclus, totclus, dfree;

        if (!redir_drive_prefix[drive]) return 0x01FF;  /* Can't select */

        if (!GetDiskFreeSpace(redir_drive_prefix[drive], &secclus, &bps, &freeclus, &totclus))
		return 0x01FF;	/* Can't select */
	dfree = freeclus * (secclus * bps / 128);

	if (dfree < freeclus ||		/* Calculation has wrapped round */
	    dfree > 4194303L)           /* Bigger than max CP/M drive size */
	{
		dfree = 4194303L;
	}
#else
	struct statfs buf;
	long dfree;

	if (!redir_drive_prefix[drive]) return 0x01FF;	/* Can't select */
	
	if (statfs(redir_drive_prefix[drive], &buf)) return 0x01FF;

	dfree = (buf.f_bavail * (buf.f_bsize / 128));

	if (dfree < buf.f_bavail ||	/* Calculation has wrapped round */
	    dfree > 4194303L)           /* Bigger than max CP/M drive size */
	{
		dfree = 4194303L;
	}
#endif

	redir_wr24(dma, dfree);
	return 0;
}