Re: How do I check if a file is empty in C??



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.
.



Relevant Pages

  • Re: How do I check if a file is empty in C??
    ... 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?? ... (Is there a potential flaw in this definition? ... some data, it is not empty. ...
    (comp.lang.c)
  • Re: Old playlist cannot be deleted, new playlists do not appear MP
    ... Under WMP's Monitor Folders list, is that still populated, or is that empty? ... Playlist item in the tree I don't have an option to "view all". ... none of my existing playlists are ... although the .wpl file is presnt on my computer. ...
    (microsoft.public.windowsmedia.player)
  • Re: ITunes - find songs not in a playlist?
    ... In article, sbt ... the track's playlists is empty. ... The script requires no prompting except for a few initial ...
    (comp.sys.mac.apps)
  • Playlist with multiple users
    ... I have WindowsXP with multiple users. ... would have separate playlists. ... up empty. ...
    (microsoft.public.windowsxp.music)
  • Playlist with multiple users
    ... I have WindowsXP with multiple users. ... would have separate playlists. ... up empty. ...
    (microsoft.public.windowsmedia.player)