home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
FREE.ZIP
/
FREE.BAS
next >
Wrap
BASIC Source File
|
1990-08-12
|
5KB
|
116 lines
' --- FREE 1.2 - OS/2 by Stu Sims
' --- Copyright (C) 1989,1990 Stuart P. Sims
' Software Technologies
' 1825 23rd Avenue
' San Francisco, CA 94122
' USA
' (415) 731-2222
' "Free 1.2" - OS/2 - A utility to show available disk space and drive
' statistics. Inspired by Art Merrill's similar utility
' for DOS. Demonstrates use of system calls and standard
' error handling using OS/2 and BC.
'
' The right to use this software in its original unmodified form is granted
' for non-commercial purposes. Commercial users should contact
' Software Technologies for details on site licensing.
'
' Inquiries and comments may also be sent through CIS to Stu Sims (74146,2010)
'
' This program was created using the QB environment running in the DOS box
' and compiled in protected mode.
'
' Modification History
' July 10, 1989 Version 1.0 BC 6.0
' November 10, 1989 Version 1.1 add support for drive parameter on
' command line
' August 12, 1990 Version 1.2 - support for drives up to 99 gigabytes
' recompiled with BC 7.1 using PWB
'
DEFINT A-Z
REM $INCLUDE: 'bsedosfl.bi'
REM $INCLUDE: 'bsedospc.bi'
CONST QFSInfoBufferSize = 18 ' Size in bytes of required buffer to
' receive disk information
CONST QFSLabelBufferSize = 255 ' Size of label buffer
TYPE QFSInfoLevelOne
FileSystemID AS LONG
SectorsPerAllocUnit AS LONG
TotalAllocUnit AS LONG
AvailableAllocUnit AS LONG
BytesPerSector AS INTEGER
END TYPE
TYPE QFSInfoLevelTwo
VolumeLabelDate AS INTEGER
VolumeLabelTime AS INTEGER
VolumeLabelLength AS STRING * 1
VolumeLabel AS STRING * QFSLabelBufferSize
END TYPE
TYPE GetMessageInsertStrings
InsertStrings AS STRING * 256
END TYPE
DIM FreeDiskSpace AS LONG
DIM TotalDiskSpace AS LONG
DIM QFSInfoBuffer AS QFSInfoLevelOne
DIM QFSLabelBuffer AS QFSInfoLevelTwo
DIM GetMessageBuffer AS STRING * 1024
DIM GetMessageLength AS INTEGER
DIM MessageFileString AS STRING * 256
MessageFileString = "OSO001.MSG" + CHR$(0) ' ASCIIZ string with OS/2
' message file name
Drive = 0 ' Set default drive to current drive
IF LEN(COMMAND$) <> 0 THEN ' Convert 1st character to
Drive = ASC(LEFT$(COMMAND$, 1)) - ASC("A") + 1 ' a drive number
END IF
' --- Check that drive exists and is working.
' Get volume label (if any).
ReturnCode = DosQFSInfo(Drive, 2, VARSEG(QFSLabelBuffer), VARPTR(QFSLabelBuffer), QFSLabelBufferSize)
SELECT CASE ReturnCode
CASE 0 ' Has a volume label
Length = ASC(QFSLabelBuffer.VolumeLabelLength)
Label$ = LEFT$(QFSLabelBuffer.VolumeLabel, Length)
CASE 125 ' No volume label
Label$ = "Unlabeled Disk"
Length = LEN(Label$)
CASE ELSE ' Invalid disk or other error, use OS/2 error
' code to print error message, then exit.
MessageFileSeg = VARSEG(MessageFileString)
MessageFileOffset = VARPTR(MessageFileString)
MessageFile = DosGetMessage(MessageFileSeg, MessageFileOffset, 0, VARSEG(GetMessageBuffer), VARPTR(GetMessageBuffer), 1024, ReturnCode, MessageFileSeg, MessageFileOffset, SEG GetMessageLength)
PRINT LEFT$(GetMessageBuffer, GetMessageLength)
CALL DosExit(2, ReturnCode) ' Pass return code to caller
END SELECT
' --- Get drive information
ReturnCode = DosQFSInfo(Drive, 1, VARSEG(QFSInfoBuffer), VARPTR(QFSInfoBuffer), QFSInfoBufferSize)
IF ReturnCode <> 0 THEN ' This is unlikely, but...
CALL DosExit(1, ReturnCode)
END IF
' --- Calculate free disk space and total disk space
FreeDiskSpace = QFSInfoBuffer.SectorsPerAllocUnit * QFSInfoBuffer.AvailableAllocUnit * QFSInfoBuffer.BytesPerSector
TotalDiskSpace = QFSInfoBuffer.SectorsPerAllocUnit * QFSInfoBuffer.TotalAllocUnit * QFSInfoBuffer.BytesPerSector
PRINT
PRINT "Free 1.2 - OS/2 by Stu Sims"
PRINT
PRINT Label$; " Statistics"
PRINT USING "##,###,###,### Allocation Units"; QFSInfoBuffer.TotalAllocUnit
PRINT USING "##,###,###,### Sectors per Allocation Unit"; QFSInfoBuffer.SectorsPerAllocUnit
PRINT USING "##,###,###,### Bytes per Sector"; QFSInfoBuffer.BytesPerSector
PRINT USING "##,###,###,### Bytes total disk space"; TotalDiskSpace
PRINT USING "##,###,###,### Bytes allocated"; TotalDiskSpace - FreeDiskSpace
PRINT USING "##,###,###,### Bytes free"; FreeDiskSpace
END