Using std::filesystem::perms you can get the permissions set on a file. I want to check if I have access to read and write to a file. Using this method works if I am the owner of the file. If I am not the owner of the file (for example root owns it), then the perms returned isn't that useful for the task at hand without knowing the owner.
https://stackoverflow.com/a/7328340 explains how to get the file owner and the current user on Linux systems which can be used in conjunction with std::filesystem::perms for a solution on Linux that is not POSIX compliant.
Is there a way to check if the current user current user can read or write to a file in a POSIX compliant way? Can this be done using only the C++ std lib? What about with Boost?
https://stackoverflow.com/a/10682224 suggests that ownership can not be detected using boost. https://stackoverflow.com/a/59899055 suggests that interpreting the file permissions isn't always that meaningful, but I just want to know if I can read from the file before I attempt opening it.