1. Re: FAT32 HELP! -- finally squashed it
- Posted by Wes Hamilton <whamilton at WMRLS.ORG>
Aug 22, 1999
-
Last edited Aug 23, 1999
Hi Everyone,
Nevermind my previous post. I simply needed to initialize the buffer. The
working code is below (Craig, I'm sure you'll want to update diskutil.e when
you get back from vacation -- lucky, hope it was nice). Thanks again
everyone for your help on this; this is a great list and I'll be sticking
around for a while I'm sure...
Wes
------------modification to Craig G's diskutil.e--------------------------
.
.
.
global function disk_free_space_ex(integer letter)
-- get current free space on specified drive
-- Returns: {free space,total space} in bytes
-- if the specified drive does not exist, you will get -1
-- Note: You will get a critical error if the drive is not ready; see
-- the func check_drive().
-- 8/22/1999 Modified to use INT21h, AX=7303h for FAT32 - W.C.Hamilton
atom bytes_per_sector, sectors_per_cluster, free_clusters, total_clusters
atom free_space, total_space
atom NameBuffer, ResultBuffer
if not drive_exist(letter) then
return -1
end if
NameBuffer = allocate_low(4)
if not NameBuffer then
return -1
end if
poke(NameBuffer,letter & ":\\" & 0)
ResultBuffer = allocate_low(44)
if not ResultBuffer then
free_low(NameBuffer)
return -1
end if
poke(ResultBuffer, repeat(0,44))
mregs = repeat(0,10)
mregs[REG_AX] = #7303
mregs[REG_CX] = 44
mregs[REG_DS] = floor(NameBuffer/16)
mregs[REG_DX] = remainder(NameBuffer,16)
mregs[REG_ES] = floor(ResultBuffer/16)
mregs[REG_DI] = remainder(ResultBuffer,16)
mregs = dos_interrupt(#21,mregs)
free_low(NameBuffer)
if and_bits(mregs[REG_FLAGS],1) then
free_low(ResultBuffer)
return -1
end if
bytes_per_sector = peek4u(ResultBuffer + 8)
sectors_per_cluster = peek4u(ResultBuffer + 4)
free_clusters = peek4u(ResultBuffer + 12)
total_clusters = peek4u(ResultBuffer + 16)
free_space = bytes_per_sector * sectors_per_cluster * free_clusters
total_space = bytes_per_sector * sectors_per_cluster * total_clusters
free_low(ResultBuffer)
return {free_space, total_space}
end function
.
.
.
--------------------------------------------------------------------