directory listings in programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You're right, it's more then I was looking for, but it looks like it
will do just what I want.
Thanks.

Greg


On Sat, May 15, 2004 at 06:59:58AM -0500, Thomas Stivers wrote:
> On May 15 2004  1:35 AM, Gregory Nowak wrote:
> > Hi all.
> > 
> > I am writing a c program under gnu/Linux, in which I need to know if a
> > file of a particular name exists. The only way I can think of checking
> > for this is to attempt to open a file of a given name in read-only
> > mode. If it opens, the file exists, if the FILE stream is NULL, the
> > file doesn't exist. However, doing this for a good number of files
> > would be inefficient in my opinion. So, I was wondering if there is a
> > function which will simply tell me if a file of a given name exists or
> > not, sort of like calling ls, although I don't actually want to be
> > literally doing that either from within the program? Thanks.
> 
> It does a lot more than you're asking for, but I think the stat system
> call is what you're after. Check out man 2 stat for details. If I have
> understood things corectly stat'ing a file is more efficient than opening
> it.
> 
> -- 
> "Debugging is twice as hard as writing the code in the first place.
> Therefore, if you write the code as cleverly as possible, you are,
> by definition, not smart enough to debug it." - Brian W. Kernighan
> 
> Thomas Stivers	e-mail: stivers_t at tomass.dyndns.org
> 
> _______________________________________________
> Speakup mailing list
> Speakup at braille.uwo.ca
> http://speech.braille.uwo.ca/mailman/listinfo/speakup
> 
> 
> !DSPAM:40a60655252311627317009!
> 
> 

- -- 
Free domains: http://www.eu.org/ or mail dns-manager at EU.org

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFApgjL7s9z/XlyUyARAufvAJ4jmTOM+yqjLGTWB/XavWDLqe9f7gCeNc4h
nFEfxM7MzTDSS/meKrf/QTc=
=Vcf4
-----END PGP SIGNATURE-----




[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux