santosh wrote:
>
On Friday 20 Jul 2007 11:50 am, Guru Jois <gu*******@gmail.comwrote
in message <11**********************@i13g2000prf.googlegroups .com>:
On Jul 19, 11:11 am, ashu <ashishmoury...@gmail.comwrote:
i want to create a program that checks if file is readable and
writable ? any help will be great.
you can achieve it by using access(2), not sure about portability,
I am bad in which.
access is not Standard C. It's required in POSIX, among other
standards. The OP should preferably be directed to post in a system
specific group.
But even under POSIX, access() has "issues".
Why not fopen(filename,"r+") and see if it succeeds? Yes, it is
possible for this to fail for some reason, even if the file is
readable and writable, but it's probably the closest thing to a
portable solution. (And, if the file can't be opened even though
it is readable and writable, does it really matter that the file
permissions are okay?)
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody |
www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net |
www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>