From 065ede0ae7c13641ac5d9bccf088a8273163f5e3 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 21 Dec 2009 11:17:13 +0200 Subject: Fix User/Group Name lookups on *unix file-systems. Removable media might have group or user ID's not available on the new host system. Name lookups will then fail. This patch works around that issue. --- src/corelib/x11/fpg_x11.pas | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/x11/fpg_x11.pas b/src/corelib/x11/fpg_x11.pas index 09305c1e..036b0408 100644 --- a/src/corelib/x11/fpg_x11.pas +++ b/src/corelib/x11/fpg_x11.pas @@ -2388,10 +2388,19 @@ begin Result.IsExecutable := ((sr.Mode and $40) <> 0); Result.mode := EncodeModeString(sr.Mode); Fpstat(PChar(fullname), info); - {Result.GroupID := info.st_gid; - Result.OwnerID := info.st_uid;} - Result.Owner := GetUserName(TUID(info.st_uid)); - Result.Group := GetGroupName(TGID(info.st_uid)); + // Especially if files are transfered on removable media the host system + // might not have those user or group ids. So name lookups will fail. This + // simply returns the ID's in such cases. + try + Result.Owner := GetUserName(TUID(info.st_uid)); + except + Result.Owner := IntToStr(info.st_uid); + end; + try + Result.Group := GetGroupName(TGID(info.st_gid)); + except + Result.Group := IntToStr(info.st_gid); + end; end; end; -- cgit v1.2.3-70-g09d2