summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-02-24 18:59:48 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-02-27 18:51:33 +0000
commitb6541ea945620f8db0b3875e09eb462b85e37623 (patch)
tree90e4f9fb88796c217441f9543691a1a9ed1e386c
parentcc067bd72d80f678aa7c1109c123581ff0fede77 (diff)
downloadbuildstream-b6541ea945620f8db0b3875e09eb462b85e37623.tar.gz
_filebaseddirectory.py: Add _get_filetype() method
-rw-r--r--buildstream/storage/_filebaseddirectory.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/buildstream/storage/_filebaseddirectory.py b/buildstream/storage/_filebaseddirectory.py
index dfb310ae1..67c0ec630 100644
--- a/buildstream/storage/_filebaseddirectory.py
+++ b/buildstream/storage/_filebaseddirectory.py
@@ -189,3 +189,19 @@ class FileBasedDirectory(Directory):
""" Returns the underlying (real) file system directory this
object refers to. """
return self.external_directory
+
+ def _get_filetype(self, name=None):
+ path = self.external_directory
+
+ if name:
+ path = os.path.join(path, name)
+
+ st = os.lstat(path)
+ if stat.S_ISDIR(st.st_mode):
+ return _FileType.DIRECTORY
+ elif stat.S_ISLNK(st.st_mode):
+ return _FileType.SYMLINK
+ elif stat.S_ISREG(st.st_mode):
+ return _FileType.REGULAR_FILE
+ else:
+ return _FileType.SPECIAL_FILE