diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-06-04 13:40:54 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2013-06-05 13:12:46 +0000 |
commit | 5fefb7bce27b7642d4410f2f09c7891ca4378c9e (patch) | |
tree | 9550ad3280d67c3ed7df785faeb6ca2549112c0a /morphlib | |
parent | 4ef447a3a61b4d37e411bf37b2c2f7360d123f60 (diff) | |
download | morph-5fefb7bce27b7642d4410f2f09c7891ca4378c9e.tar.gz |
S7904: add method for finding bytes free in path
This has no tests, as the ability to run them requires root privilidges
or a more recent kernel and user namespace support.
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/util.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/morphlib/util.py b/morphlib/util.py index 6d15fcfe..007c7f7c 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -13,6 +13,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import os import re import morphlib @@ -219,3 +220,9 @@ def copyfileobj(inputfp, outputfp, blocksize=1024*1024): # pragma: no cover elif sparse: outputfp.seek(-1, os.SEEK_CUR) outputfp.write("\x00") + +def get_bytes_free_in_path(path): # pragma: no cover + """Returns the bytes free in the filesystem that path is part of""" + + fsinfo = os.statvfs(path) + return fsinfo.f_bavail * fsinfo.f_bsize |