2018-06-21 04:05:24 +03:00
|
|
|
#!/usr/bin/env python3
|
2019-06-20 02:58:25 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
2018-06-21 04:05:24 +03:00
|
|
|
#
|
2019-06-20 02:58:25 +03:00
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
2018-06-21 04:05:24 +03:00
|
|
|
|
|
|
|
import abc
|
2019-12-20 01:47:42 +03:00
|
|
|
import os
|
2018-06-21 04:05:24 +03:00
|
|
|
|
|
|
|
from . import util
|
|
|
|
|
|
|
|
|
|
|
|
class FsUtil(abc.ABC):
|
|
|
|
@abc.abstractmethod
|
|
|
|
def mkdir_p(self, path: str) -> str:
|
|
|
|
"""Performs `mkdir -p <path>` and returns the path."""
|
|
|
|
|
2019-12-20 01:47:42 +03:00
|
|
|
@abc.abstractmethod
|
|
|
|
def statvfs(self, path: str) -> os.statvfs_result:
|
|
|
|
"""Calls os.statvfs on the mount"""
|
|
|
|
|
2018-06-21 04:05:24 +03:00
|
|
|
|
|
|
|
class LinuxFsUtil(FsUtil):
|
|
|
|
def mkdir_p(self, path: str) -> str:
|
|
|
|
return util.mkdir_p(path)
|
2019-12-20 01:47:42 +03:00
|
|
|
|
|
|
|
def statvfs(self, path: str) -> os.statvfs_result:
|
|
|
|
return os.statvfs(path)
|