Is there a way to find out free disk space equivalent to psutil.disk_usage('/') in python



Is there a way to find out free disk space in drive C: both on windows and linux ?
On python I would that by calling


It seems not…

If you are OK with using python from Julia you could probably use:

julia> using PyCall

julia> @pyimport shutil

julia> shutil.disk_usage("/")

If you like to play with lower level (see doc) you could write something similar to:

julia> function disk_free_space(path)
          if Sys.islinux()  # maybe isunix would work here too?
            statfs = zeros(UInt64, 11)  # warning: I am not sure all platform use unsigned long for all fields. See `man statvfs`
            ccall((:statvfs, ""), Cint, (Cstring,Ptr{Cvoid}), "/", statfs)
            convert(Int, statfs[1]*statfs[5])
          elseif Sys.iswindows()
             # you could call GetDiskFreeSpaceExA from kernel32.dll 
             # something like ->
             # ccall( (:GetDiskFreeSpaceExA, "kernel32.dll"), stdcall, ... )  
             # sry I have no windows to try
          else throw(ErrorException("Unsupported platform"))


Thanks I like the low level solution…