From 64378046ac38f23f45f0c5f224f71cecb35dcae1 Mon Sep 17 00:00:00 2001 From: Ground0 Date: Thu, 4 Jul 2019 17:25:16 +0200 Subject: [PATCH] Original statvfs.pbi von Chabba.de --- SYS/lhs_statvfs.pbi | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 SYS/lhs_statvfs.pbi diff --git a/SYS/lhs_statvfs.pbi b/SYS/lhs_statvfs.pbi new file mode 100644 index 0000000..2f669cb --- /dev/null +++ b/SYS/lhs_statvfs.pbi @@ -0,0 +1,68 @@ +; Module/File: System_FreeDiscSpace.pb +; 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 +;-------------------------------------------------------------- + + +EnableExplicit + +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 + +Structure DriveInfoResult + Size.q + Used.q + Free.q +EndStructure + +ImportC "" + statvfs.l(Path.p-utf8, *value.Statvfs) +EndImport + +Global Drive.DriveInfoResult + + + +Procedure.q DriveInfo(Path.s, *Result.DriveInfoResult) + Protected v.statvfs + Statvfs(Path, v) + *Result\Size= v\f_blocks * v\f_frsize + *Result\Used= (v\f_blocks - v\f_bfree) * v\f_frsize + *Result\Free= v\f_bavail * v\f_frsize +EndProcedure + + +DriveInfo(GetHomeDirectory(), Drive); choose any directory from drive of interrest +Debug "Drive-Info: " + GetHomeDirectory() +Debug "Size: " + Str(Drive\Size) +Debug "Used: " + Str(Drive\Used) +Debug "Free: " + Str(Drive\Free) +Debug "---" +; +; DriveInfo("/media/charly/96A2-6D58/", Drive); choose your USB-Stick +; Debug "Drive-Info: " + "/media/charly-xubuntu/96A2-6D58/" +; Debug "Size: " + Str(Drive\Size) +; Debug "Used: " + Str(Drive\Used) +; Debug "Free: " + Str(Drive\Free) +; Debug "---" \ No newline at end of file