I have for the last few hours been looking up how to get and set the user ID, group ID, and file permissions, flags and other important information of a file using C++. I have seen code examples and my current code works wonders on Linux, which uses and
My current "Get User ID" code looks like this, and I will be adding #if defines to check OS and use OS specific gets / sets.
My question is rather broad, but if I could be pointed to some sort of universal library to do this, I would greatly appreciate it. Honestly anything that works on Mac, Linux and Windows would interest me. I've tried looking and only have come up with stat, which returns something similar to this: Owner: 1465530688
long perms::getUID(string filename)
{
struct stat info;
stat(filename.c_str(), &info);
printf("Owner: %ld\n", (long)info.st_uid);
return (long)info.st_uid;
}