|
Home > Archive > Unix Programming > October 2005 > How to check if a directory exists using C++
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to check if a directory exists using C++
|
|
| jessie 2005-10-24, 3:48 pm |
| Unix OS
Thanks.
| |
| Gordon Burditt 2005-10-24, 3:48 pm |
| >Subject: Re: How to check if a directory exists using C++
>Unix OS
stat(). This also lets you check if it IS a directory vs. something
else.
access() is also a possibility, but it has a lot of odd problems
if effective ids != real ids, something which can happen even if
the program isn't setuid.
Gordon L. Burditt
| |
| jessie 2005-10-24, 3:48 pm |
| Can you post detail syntax please?
And which header file should be included?
Thanks
"Gordon Burditt" <gordonb.4r8hm@burditt.org> wrote in message
news:11ligvir95ip8b5@corp.supernews.com...
>
> stat(). This also lets you check if it IS a directory vs. something
> else.
>
> access() is also a possibility, but it has a lot of odd problems
> if effective ids != real ids, something which can happen even if
> the program isn't setuid.
>
> Gordon L. Burditt
| |
| joe@invalid.address 2005-10-24, 3:48 pm |
| "jessie" <jessiezyt@hotmail.com> writes:
> Can you post detail syntax please?
> And which header file should be included?
If you're going to write programs for unix, you should become familiar
with how to use the man program. When someone recommends a function
that you want more information about, for example stat(), type
man stat
Sometimes you have to specify the section of the manual to search. To
find out how man works, type
man man
Another alternative, if you want to be POSIXly correct, is to access
the Open Group web site:
http://www.opengroup.org/onlinepubs/009695399/
Joe
--
Gort, klatu barada nikto
| |
| jessie 2005-10-24, 3:48 pm |
| Thanks a lot
<joe@invalid.address> wrote in message
news:m31x2ebp15.fsf@invalid.address...
> "jessie" <jessiezyt@hotmail.com> writes:
>
>
> If you're going to write programs for unix, you should become familiar
> with how to use the man program. When someone recommends a function
> that you want more information about, for example stat(), type
>
> man stat
>
> Sometimes you have to specify the section of the manual to search. To
> find out how man works, type
>
> man man
>
> Another alternative, if you want to be POSIXly correct, is to access
> the Open Group web site:
>
> http://www.opengroup.org/onlinepubs/009695399/
>
> Joe
> --
> Gort, klatu barada nikto
| |
| Philip Paeps 2005-10-24, 3:48 pm |
| Gordon Burditt <gordonb.4r8hm@burditt.org> wrote:
>
> stat(). This also lets you check if it IS a directory vs. something else.
If you're planning to use this as a test before you open it, you might
consider handling your errors from the open() call instead to avoid
interesting surprises when the directory gets created/deleted or suddenly
becomes a completely different kind of file between your stat() and your
open().
- Philip
--
Philip Paeps Please don't email any replies
philip@paeps.cx I follow the newsgroup.
Real programmers understand Pascal.
|
|
|
|
|