home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 242,361 of 243,242   
   Richard Heathfield to Richard Harnden   
   Re: is_binary_file()   
   07 Dec 25 21:51:36   
   
   From: rjh@cpax.org.uk   
      
   On 07/12/2025 19:01, Richard Harnden wrote:   
   > On 06/12/2025 01:05, Michael Sanders wrote:   
   >> Am I close? Missing anything you'd consider to be (or not)   
   >> needed?   
   >   
   > A text file is supposed to end with a '\n' (M$, of course,   
   > largely ignores this convention), but a quick test could be:   
   >   
   > f = fopen(path, "rb");   
   >   
   > fseek(f, -1, SEEK_END);   
      
   Not guaranteed to work with binary files...   
      
   7.19.9.2(3)   
      
   A binary stream need not meaningfully support fseek calls with a   
   whence value of SEEK_END.   
      
   ...or text files.   
      
   7.19.9.2(4)   
      
   For a text stream, either offset shall be zero, or offset shall   
   be a value returned by an earlier successful call to the ftell   
   function on a stream associated with the same file and whence   
   shall be SEEK_SET.   
      
   --   
   Richard Heathfield   
   Email: rjh at cpax dot org dot uk   
   "Usenet is a strange place" - dmr 29 July 1999   
   Sig line 4 vacant - apply within   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca