def get_free_space_in_dir(path):
 if sys.platform.startswith(u'win'):
  import ctypes
  free_bytes = ctypes.c_ulonglong(0)
  retval = ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(path), None, None, ctypes.pointer(free_bytes))
  if (retval == 0):
   raise IOError(u'Checking free space on {!r} failed unexpectedly.'.format(path))
  return free_bytes.value
 else:
  stat = os.statvfs(path)
  return (stat.f_bavail * stat.f_frsize)

def get_free_space_in_dir ( path ) : if sys . platform . startswith ( u'win' ) : import ctypes free_bytes = ctypes . c_ulonglong ( 0 ) retval = ctypes . windll . kernel32 . GetDiskFreeSpaceExW ( ctypes . c_wchar_p ( path ) , None , None , ctypes . pointer ( free_bytes ) ) if ( retval == 0 ) : raise IOError ( u'Checking free space on {!r} failed unexpectedly.' . format ( path ) ) return free_bytes . value else : stat = os . statvfs ( path ) return ( stat . f_bavail * stat . f_frsize )
given a path to a directory .