× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



ian wrote:
If I use the stat() API it gives the User ID of the Owner as a numeric
field. How do I convert this to the Owner name ?

The getpwuid() API will give you the username. There's also a getgrgid() API for the group profile that owns the file (you didn't ask about that, but it might also be of interest.)

Here's an excerpt from one of my programs:
D owner s 10a
D groupx s 10a

D info ds likeds(statds64)
D own ds likeds(passwd)
D based(p_own)
D grp ds likeds(group)
D based(p_grp)

path = %trim(dirname) + '/' + filename;
if (lstat64(path: info) = -1);
// handle error
endif;

p_own = getpwuid(info.st_uid);
if (p_own = *null);
owner = %char(info.st_uid);
else;
owner = %str(own.pw_name);
endif;

p_grp = getgrgid(info.st_gid);
if (p_grp = *null);
groupx = %char(info.st_gid);
else;
groupx = %str(grp.gr_name);
endif;


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.