From 982a8aec9fafc0890e6da862ec87bc567c939612 Mon Sep 17 00:00:00 2001 From: mainzelm Date: Wed, 5 Apr 2006 07:38:50 +0000 Subject: [PATCH] Introduce save versions of ->username and ->groupname that return the UID as a string if the system does not know the corresponding name. --- scheme/browse-directory-list.scm | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scheme/browse-directory-list.scm b/scheme/browse-directory-list.scm index c116b55..d8067b1 100644 --- a/scheme/browse-directory-list.scm +++ b/scheme/browse-directory-list.scm @@ -65,13 +65,28 @@ (else (number->string bytes))))) +(define (->username/save uid/name) + (with-fatal-error-handler + (lambda (condition more) + (if (number? uid/name) + (number->string uid/name) + uid/name)) + (->username uid/name))) + +(define (->groupname/save gid/name) + (with-fatal-error-handler + (lambda (condition more) + (if (number? gid/name) + (number->string gid/name) + gid/name)) + (->groupname gid/name))) + (define (format-user/group fi) (fill-up-string 17 (string-append - (cut-to-size 8 (->username (file-info:uid fi))) + (cut-to-size 8 (->username/save (file-info:uid fi))) ":" - (cut-to-size 8 (group-info:name - (group-info (file-info:gid fi))))))) + (cut-to-size 8 (->groupname/save (file-info:gid fi)))))) ;; leave one line for the heading (define (calculate-number-of-lines result-buffer)