+ return stat_result.from_xstat_rep(_helpers.lstat(path))
+
+
+def mode_str(mode):
+ result = ''
+ # FIXME: Other types?
+ if pystat.S_ISREG(mode):
+ result += '-'
+ elif pystat.S_ISDIR(mode):
+ result += 'd'
+ elif pystat.S_ISCHR(mode):
+ result += 'c'
+ elif pystat.S_ISBLK(mode):
+ result += 'b'
+ elif pystat.S_ISFIFO(mode):
+ result += 'p'
+ elif pystat.S_ISLNK(mode):
+ result += 'l'
+ elif pystat.S_ISSOCK(mode):
+ result += 's'
+ else:
+ result += '?'
+
+ result += 'r' if (mode & pystat.S_IRUSR) else '-'
+ result += 'w' if (mode & pystat.S_IWUSR) else '-'
+ result += 'x' if (mode & pystat.S_IXUSR) else '-'
+ result += 'r' if (mode & pystat.S_IRGRP) else '-'
+ result += 'w' if (mode & pystat.S_IWGRP) else '-'
+ result += 'x' if (mode & pystat.S_IXGRP) else '-'
+ result += 'r' if (mode & pystat.S_IROTH) else '-'
+ result += 'w' if (mode & pystat.S_IWOTH) else '-'
+ result += 'x' if (mode & pystat.S_IXOTH) else '-'
+ return result
+
+
+def classification_str(mode, include_exec):
+ if pystat.S_ISREG(mode):
+ if include_exec \
+ and (pystat.S_IMODE(mode) \
+ & (pystat.S_IXUSR | pystat.S_IXGRP | pystat.S_IXOTH)):
+ return '*'
+ else:
+ return ''
+ elif pystat.S_ISDIR(mode):
+ return '/'
+ elif pystat.S_ISLNK(mode):
+ return '@'
+ elif pystat.S_ISFIFO(mode):
+ return '|'
+ elif pystat.S_ISSOCK(mode):
+ return '='
+ else:
+ return ''