Scott,
Thanks for that, I will give this method a try.
I quite like the stat() approach because its relatively straight
forward.
I have got the QSYRTVUA API working now as suggested by Emmanuel & its
OK.
It will be useful to compare the two approaches.
For the interest of the list, the reason to see who owns an IFS object
is because in our case they are created by a Windows application, not
iSeries, and we occasionally hit problems over the authorities.
It seems QUSER gets to own the objects, but not always.
Regards
Ian Patterson
Grange IT Limited
tel 01947 880458
fax 01947 880439
www.grangesystems.com
* Bacstel-iP systems for Windows and IBM iSeries
* CHECKER Bank Account details Authetication systems
* Inland Revenue submission systems
* HMRC Data Provisioning systems
Grange IT Limited, Registered in England No. 5017635. Registered Office:
62-63 Westborough, Scarborough YO11 1TS
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: 21 August 2007 17:48
To: RPG programming on the AS400 / iSeries
Subject: Re: retrieving an IFS object owner
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.