From 57435fbf56e83fe9b73d51771b853b34cd7f41db Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 15:53:02 +0200 Subject: fsobject.fsobject: display more information added attributes is_socket and is_fifo add special file info to infostring --- ranger/fsobject/fsobject.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index ada00bb0..f2f440c1 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -47,6 +47,8 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): runnable = False is_link = False is_device = False + is_socket = False + is_fifo = False readlink = None stat = None infostring = None @@ -175,6 +177,8 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): pass mode = self.stat.st_mode self.is_device = bool(stat.S_ISCHR(mode) or stat.S_ISBLK(mode)) + self.is_socket = bool(stat.S_ISSOCK(mode)) + self.is_fifo = bool(stat.S_ISFIFO(mode)) self.accessible = True if self.accessible and os.access(self.path, os.F_OK): @@ -197,7 +201,14 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.infostring = ' ' + human_readable(self.stat.st_size) else: self.type = T_UNKNOWN - self.infostring = None + if self.is_device: + self.infostring = 'dev' + elif self.is_fifo: + self.infostring = 'fifo' + elif self.is_socket: + self.infostring = 'sock' + else: + self.infostring = None else: if self.is_link: @@ -215,10 +226,10 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): if self.permissions is not None: return self.permissions - if self.accessible is False: - return '----------' - - mode = self.stat.st_mode + try: + mode = self.stat.st_mode + except: + return '----??----' if stat.S_ISDIR(mode): perms = ['d'] -- cgit 1.4.1-2-gfad0