A procedure:
Code: Select all
Procedure GetFolderSize( dir.s )
dh=ExamineDirectory(#PB_Any,dir,"*") : If dh
While NextDirectoryEntry(dh)
nm.s=DirectoryEntryName(dh)
If DirectoryEntryType(dh)=#PB_DirectoryEntry_Directory
If nm<>"." And nm<>".."
sz=sz+GetFolderSize(dir+"/"+nm) : Debug dir+"/"+nm+" "+Str(sz)
EndIf
Else
sz=sz+DirectoryEntrySize(dh)
EndIf
Wend
If IsDirectory(dh) : FinishDirectory(dh) : EndIf
Else
;PrintN("No dir!")
EndIf
ProcedureReturn sz
EndProcedure
Debug GetFolderSize("/home")
Code: Select all
du -bchecking the purebasic folder size returns 22643082 with the above function, 23118218 with du
[...]/purebasic/examples/sources/data should be 875469 for the above, 879565 for du

