As in description. I need to find out who own a file using cpp code, i am using boost filesystem, codeblocks on ubuntu 12.04 (which is irrelevant, but). If anyone could give me function name, or reference link, to particular function, i would be greatful.
Asked
Active
Viewed 73 times
1 Answers
0
boost::filesystem
does not support this functionality, you can obtain file attributes, but that's it.
Something like this should work:
#include <sys/stat.h>
struct stat st;
stat("myFile.txt", &st);
struct passwd *pw = getpwuid(st.st_uid);
struct group *gr = getgrgid(st.st_gid);
Note: The previous code is not error safe, that's up to you

ichramm
- 6,437
- 19
- 30
-
With, the appropriate function on the `path` to get the name in the system dependent format, since he's using `boost::filesystem`. (And error checking, of course.) – James Kanze Jan 28 '14 at 18:52