[英]Ubuntu file ownership cpp
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). 我需要找出谁拥有使用cpp代码的文件,我使用的是boost文件系统,以及ubuntu 12.04上的代码块(无关紧要,但是)。 If anyone could give me function name, or reference link, to particular function, i would be greatful. 如果有人可以给我特定功能的功能名称或引用链接,我将非常感激。
boost::filesystem
does not support this functionality, you can obtain file attributes, but that's it. boost::filesystem
不支持此功能,您可以获取文件属性,仅此而已。
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 注意:先前的代码不是错误安全的,这取决于您
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.