Re: Freier Festplatten speicher?
Verfasst: 01.08.2010 13:57
Ok, neue Variante mit statvfs().
Code: Alles auswählen
; struct statvfs {
; unsigned long f_bsize; /* file system block size */
; unsigned long f_frsize; /* fragment size */
; fsblkcnt_t f_blocks; /* size of fs in f_frsize units */
; fsblkcnt_t f_bfree; /* # free blocks */
; fsblkcnt_t f_bavail; /* # free blocks for non-root */
; fsfilcnt_t f_files; /* # inodes */
; fsfilcnt_t f_ffree; /* # free inodes */
; fsfilcnt_t f_favail; /* # free inodes for non-root */
; unsigned long f_fsid; /* file system ID */
; unsigned long f_flag; /* mount flags */
; unsigned long f_namemax; /* maximum filename length */
; };
Structure STATVFS
f_bsize.i
f_frsize.i
f_blocks.i
f_bfree.i
f_bavail.i
f_files.i
f_ffree.i
f_favail.i
f_fsid.i
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
__f_unused.l
CompilerEndIf
f_flag.i
f_namemax.i
__f_spare.l[6]
EndStructure
Enumeration
#ST_RDONLY = 1
#ST_NOSUID = 2
EndEnumeration
ImportC ""
statvfs.l(path.p-utf8, *buf.STATVFS)
EndImport
stats.STATVFS
If statvfs("/", @stats) = 0
size.s = StrU(stats\f_bavail * stats\f_bsize / 1024 / 1024, #PB_Quad)
Debug "Free for non-root: " + size + " MB"
Debug "Max file name length: " + StrU(stats\f_namemax)
Debug "File system ID: " + Hex(stats\f_fsid)
If stats\f_flag & #ST_RDONLY
Debug "readonly"
Else
Debug "not readonly"
EndIf
EndIf