mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 16:29:21 +02:00
* fix DiskFree and DiskSize to check for Drive argument
git-svn-id: trunk@11226 -
This commit is contained in:
parent
cb5d95a43d
commit
6433f8c38b
@ -649,8 +649,8 @@ Function DiskFree(Drive: Byte): int64;
|
|||||||
var
|
var
|
||||||
fs : tstatfs;
|
fs : tstatfs;
|
||||||
Begin
|
Begin
|
||||||
if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and (statfs(StrPas(fixdrivestr[drive]),fs)<>-1)) or
|
if ((Drive in [Low(FixDriveStr)..High(FixDriveStr)]) and (not (fixdrivestr[Drive]=nil)) and (statfs(StrPas(fixdrivestr[drive]),fs)<>-1)) or
|
||||||
((not (drivestr[Drive]=nil)) and (statfs(StrPas(drivestr[drive]),fs)<>-1)) then
|
((Drive <= High(drivestr)) and (not (drivestr[Drive]=nil)) and (statfs(StrPas(drivestr[drive]),fs)<>-1)) then
|
||||||
Diskfree:=int64(fs.bavail)*int64(fs.bsize)
|
Diskfree:=int64(fs.bavail)*int64(fs.bsize)
|
||||||
else
|
else
|
||||||
Diskfree:=-1;
|
Diskfree:=-1;
|
||||||
@ -662,8 +662,8 @@ Function DiskSize(Drive: Byte): int64;
|
|||||||
var
|
var
|
||||||
fs : tstatfs;
|
fs : tstatfs;
|
||||||
Begin
|
Begin
|
||||||
if ((Drive<4) and (not (fixdrivestr[Drive]=nil)) and (statfs(StrPas(fixdrivestr[drive]),fs)<>-1)) or
|
if ((Drive in [Low(FixDriveStr)..High(FixDriveStr)]) and (not (fixdrivestr[Drive]=nil)) and (statfs(StrPas(fixdrivestr[drive]),fs)<>-1)) or
|
||||||
((not (drivestr[Drive]=nil)) and (statfs(StrPas(drivestr[drive]),fs)<>-1)) then
|
((drive <= High(drivestr)) and (not (drivestr[Drive]=nil)) and (statfs(StrPas(drivestr[drive]),fs)<>-1)) then
|
||||||
DiskSize:=int64(fs.blocks)*int64(fs.bsize)
|
DiskSize:=int64(fs.blocks)*int64(fs.bsize)
|
||||||
else
|
else
|
||||||
DiskSize:=-1;
|
DiskSize:=-1;
|
||||||
|
Loading…
Reference in New Issue
Block a user