how to tell that a file exists and is not 0-len?

Matthew Seaman m.seaman at infracaninophile.co.uk
Wed Dec 28 23:57:27 UTC 2011


On 28/12/2011 23:50, Gary Kline wrote:

> access(filenamewithpath, F_OK) returned true  as Zero if i have
> access to it.  what do i use in C to tell me that a file is not  
> empty?  fstat?  or is there something more common?

stat(2) which uses the file path -- unless you have an open file
descriptor on the file, in which case use fstat(2).

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
JID: matthew at infracaninophile.co.uk               Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20111228/6cbd35e0/signature.pgp


More information about the freebsd-questions mailing list