Re: How do I check if a file is empty in C??
- From: Chris Torek <nospam@xxxxxxxxx>
- Date: 23 Apr 2005 19:25:45 GMT
In article <1114281095.420641.84920@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
wetherbean <bjenkin1@xxxxxxxxx> wrote:
>Hi group..I am writing a playlist management protocol where I have a
>file that holds all the playlists and a file that holds all the
>songs....before a playlist is created I need to check to see if the
>playlist file is empty so that I can assign an integer value to a
>playlist id field if it is the first playlist being written to the
>file....can anyone help?? Thanks in advance
Definition: a file is "empty" if you cannot read anything from it.
(Is there a potential flaw in this definition? [I say yes, but
this is an exercise; you are supposed to identify potential flaws,
not just answer "yes" or "no". :-) ])
Conclusion: open the file and try to read from it. If you get
some data, it is not empty. If you get EOF immediately, it is
empty.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
.
- Follow-Ups:
- Re: How do I check if a file is empty in C??
- From: Joe Wright
- Re: How do I check if a file is empty in C??
- From: Stan Milam
- Re: How do I check if a file is empty in C??
- References:
- How do I check if a file is empty in C??
- From: wetherbean
- How do I check if a file is empty in C??
- Prev by Date: Re: How do I check if a file is empty in C??
- Next by Date: Re: mutually referential (Pg 140 K&R2)
- Previous by thread: Re: How do I check if a file is empty in C??
- Next by thread: Re: How do I check if a file is empty in C??
- Index(es):
Relevant Pages
|