LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   File Permissions (https://www.linuxquestions.org/questions/programming-9/file-permissions-284370/)

fanatic_ravi 01-31-2005 03:32 AM

File Permissions
 
How to check in a C Program

wheter the given filename can have the write permission or not...

for example
suppose if a program has to create a filename

ex: ./a.out -output /home/ravi/outfile.txt

has to be created then
how do we check wheter /home/ravi is a correct directory and it has writable permissions
in the program ????
any idea????

jrtayloriv 01-31-2005 06:18 AM

man access (if you just want permissions info) or info stat (if you want more detailed info) should tell you what you are looking for, if I understood what it was that you want.

hope this helps,
jrtayloriv

itsme86 01-31-2005 10:21 AM

Usually you just try to create the file and see if fopen()/open() failed. If it fails because of permissions then errno will be set to EPERM.


All times are GMT -5. The time now is 11:55 PM.