summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-02-24 18:59:48 +0100
committerAbderrahim Kitouni <akitouni@gnome.org>2020-08-26 12:47:05 +0100
commit15ce31e49639fac91a9e2f469949756a1d84184c (patch)
tree8f6c7bb38528b84071874936032fcf60ac8c5f5a
parent719ee9dfef6f31da00898823f748379cb7322b56 (diff)
downloadbuildstream-15ce31e49639fac91a9e2f469949756a1d84184c.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 f29909a5a..a4714d729 100644
--- a/buildstream/storage/_filebaseddirectory.py
+++ b/buildstream/storage/_filebaseddirectory.py
@@ -186,3 +186,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