Re: testing for directory



On Sun, Apr 29, 2007 at 04:39:42PM -0400, Robert Huff wrote:

In C code, is there a quick and dirty way to tell if a path
points to a directory? Or do I have to open the parent directory and
check the entry for that name?

Try opening the path in question for writing with open(2). If it returns
-1, and errno is EISDIR, it is a directory.

This will be inconclusive on a read-only filesystem, or if the limit of
open file handles is reached, or for any other reason that can make
open(2) fail.

Roland
--
R.F.Smith http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)

Attachment: pgpWnpVB2anz1.pgp
Description: PGP signature



Relevant Pages

  • Re: Mouse function lost within Word 2003 document
    ... dirty workarounds but in this case there really isn't a reason to keep ... troubleshooting mode which prevents Normal.dot, add-in, and personal ... Your Winword is chewed. ... but I found a dirty work around that I am using ... ...
    (microsoft.public.word.application.errors)
  • Re: Accessing data from a subform in the parent forms recordset
    ... I had asked why you opening this form in dialog mode? ... About the only reason why you would use dialog is if you ... KEEP IN MIND if you do not edit any field in this newly opened ... And, if the above is the case, the best approach is do dirty the record ...
    (microsoft.public.access.formscoding)
  • Re: Eng v Samoa
    ... Brent Hadley wrote: ... >>> garryowen is precisely that reason, to give you a better chance of taking a ... >>> clean ball with out getting belted a nanosecond after having caught it. ... > 'tackled in the air so must be dirty play' reaction. ...
    (rec.sport.rugby.union)
  • Re: Accessing data from a subform in the parent forms recordset
    ... There is no particular reason I ... KEEP IN MIND if you do not edit any field in this newly opened ... sub-form with image table. ... And, if the above is the case, the best approach is do dirty the record ...
    (microsoft.public.access.formscoding)
  • Re: [PATCH] ppc64: Fix possible race with set_pte on a present PTE
    ... > The reason it's a bug is that if you do this, you can lose the dirty bit ... that we may just not care losing that dirty bit ... ... > the SMP fixes. ...
    (Linux-Kernel)