The most general thing to do is simply try to do what you want, then detect EPERM. You can use the access (2) system call to check if you can access a specific file in a specific way. You can check ...
Some results have been hidden because they may be inaccessible to you
Show inaccessible results