in reply to Re: file testing is hard
in thread file testing is hard

if i only wanted to open the file for reading or writing, yes. the open part isn't really my hurdle so much as the if, elsif, elsif, .. else structure surrounding it which must test the file (does it exist? can i write here? is it zero bytes? is it a directory? a plaintext file? am i opening the wrong thing?)

I want to catch any possibility (at least on my platform*) and handle it responsibly.

*nix

thanks,
jamgill

Replies are listed 'Best First'.
Re: Re: Re: file testing is hard
by ysth (Canon) on Nov 30, 2003 at 22:29 UTC
    Can you not just try to open it and see if you get an error? The only tricky part is making sure you don't allow a race condition (e.g. if the file is not there, then opening it with "+>"; but having another process create it inbetween the if and then parts).

    Update: s/is there/is not there/