How to get file's owner name in Linux using C++?

后端 未结 2 1007
慢半拍i
慢半拍i 2020-12-29 10:44

How can I get get the owner name and group name of a file on a Linux filesystem using C++? The stat() call only gives me owner ID and group ID but not the actua

2条回答
  •  鱼传尺愫
    2020-12-29 11:14

    One way would be to use stat() to get the uid of a file and then getpwuid() to get the username as a string.

提交回复
热议问题