2019-07-04 17:28:46 +02:00
|
|
|
; Original:
|
|
|
|
; -------------------------------------------------------------
|
|
|
|
; Module/File: System_FreeDiscSpace.pb
|
2019-07-04 17:25:16 +02:00
|
|
|
; Function: Get free + used Drive-space from Directory - Linux
|
|
|
|
; Author: remi_meier/uwekel (omi)
|
|
|
|
; Date: Mar. 27, 2015
|
|
|
|
; Version: 0.1
|
|
|
|
; Target Compiler: PureBasic 5.22/5.31
|
|
|
|
; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni
|
|
|
|
; Link to topic: http://www.purebasic.fr/english/viewtopic.php?f=15&t=62374
|
|
|
|
; Link to topic: http://www.purebasic.fr/german/viewtopic.php?f=21&t=22963
|
|
|
|
;--------------------------------------------------------------
|
|
|
|
|
2019-07-04 17:28:46 +02:00
|
|
|
;**************************************
|
|
|
|
;*
|
|
|
|
;* Erweitert: und Umgestellt als Modul
|
|
|
|
;*
|
|
|
|
;* lhs_statvfs.pbi
|
|
|
|
;*
|
|
|
|
;* (c) by René Linder
|
|
|
|
;*
|
|
|
|
;* Lizenz LGPL V2.1 < TODO: Abklären ob Lizenz akzeptiert wird ...
|
|
|
|
;*
|
|
|
|
;* Getesteter Compiler PureBasic 5.70/5.71b2
|
|
|
|
;*
|
2019-07-04 17:25:16 +02:00
|
|
|
|
2019-07-04 17:28:46 +02:00
|
|
|
CompilerIf #PB_Compiler_OS <> #PB_OS_Linux
|
|
|
|
CompilerError "Dieses Modul ist nur für Linux"
|
|
|
|
CompilerEndIf
|
2019-07-04 17:25:16 +02:00
|
|
|
|
2019-07-04 17:28:46 +02:00
|
|
|
DeclareModule statvfs
|
|
|
|
Declare Size(Path.s)
|
|
|
|
Declare Free(Path.s)
|
|
|
|
Declare Used(Path.s)
|
|
|
|
EndDeclareModule
|
2019-07-04 17:25:16 +02:00
|
|
|
|
2019-07-04 17:28:46 +02:00
|
|
|
Module statvfs
|
|
|
|
Structure Statvfs
|
|
|
|
f_bsize.i; file system block size
|
|
|
|
f_frsize.i; fragment size
|
|
|
|
f_blocks.i; size of fs in f_frsize units
|
|
|
|
f_bfree.i; free blocks
|
|
|
|
f_bavail.i; free blocks for unprivileged users
|
|
|
|
f_files.i; inodes
|
|
|
|
f_ffree.i; free inodes
|
|
|
|
f_favail.i; free inodes for unprivileged users
|
|
|
|
f_fsid.i; file system ID
|
|
|
|
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
|
|
|
|
__f_unused.l
|
|
|
|
CompilerEndIf
|
|
|
|
f_flag.i; mount flags: 1=readonly 2= nosuid
|
|
|
|
f_namemax.i; maximum filename length
|
|
|
|
__f_spare.l[6]
|
|
|
|
EndStructure
|
2019-07-04 17:25:16 +02:00
|
|
|
|
2019-07-04 17:28:46 +02:00
|
|
|
ImportC ""
|
|
|
|
statvfs.l(Path.p-utf8, *value.Statvfs)
|
|
|
|
EndImport
|
|
|
|
|
|
|
|
; Global Drive.DriveInfoResult
|
|
|
|
Procedure Size(Path.s)
|
|
|
|
Protected Size.i
|
|
|
|
Protected v.statvfs
|
|
|
|
Statvfs(Path, v)
|
|
|
|
Size = v\f_blocks * v\f_frsize
|
|
|
|
ProcedureReturn Size
|
|
|
|
EndProcedure
|
|
|
|
|
|
|
|
Procedure Free(Path.s)
|
|
|
|
Protected Free.i
|
|
|
|
Protected v.statvfs
|
|
|
|
Statvfs(Path, v)
|
|
|
|
Free= v\f_bavail * v\f_frsize
|
|
|
|
ProcedureReturn Free
|
|
|
|
EndProcedure
|
|
|
|
|
|
|
|
Procedure Used(Path.s)
|
|
|
|
Protected Used.i
|
|
|
|
Protected v.statvfs
|
|
|
|
Statvfs(Path, v)
|
|
|
|
Used = (v\f_blocks - v\f_bfree) * v\f_frsize
|
|
|
|
ProcedureReturn Used
|
|
|
|
EndProcedure
|
|
|
|
EndModule
|