Re: How does "cd" command work?

From: Heiko Jappe (hej_at_gis.de)
Date: 10/22/03


Date: 22 Oct 2003 09:34:45 GMT

J Peterman <J@Nospam.please> writes:
>Is there a command that will check whether a path is valid or not?

Yes, chdir() return -1 on error -- check the "errno" value like
this:

        if (chdir(path) == -1) {
                fprintf(stderr, "%s: %s\n", path, strerror(errno))
                do_what_ever_you_want();
        }

Heiko