directory listings in programs

ameer armaly ameer at charter.net
Sat May 15 16:35:30 EDT 2004


Use the access system call, but with 0 as the permission value to just see
if it exists; see the man page for more info.


On Sat, 15 May 2004, Gregory Nowak wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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.
>
> Greg
>
>
> - --
> Free domains: http://www.eu.org/ or mail dns-manager at EU.org
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.3 (GNU/Linux)
>
> iD8DBQFApboj7s9z/XlyUyARAqw3AKCe+9WAZTVAh0un22sMuEfZTQfcZwCdGcXp
> OYBDtgiIu9LgzqGy7D2ts0s=
> =D79j
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Speakup mailing list
> Speakup at braille.uwo.ca
> http://speech.braille.uwo.ca/mailman/listinfo/speakup
>




More information about the Speakup mailing list