home bbs files messages ]

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

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

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

   Message 32,407 of 33,346   
   Paul Floyd to goran.pusic@gmail.com   
   Re: Will we ever be able to throw from a   
   13 Jun 12 21:19:48   
   
   From: root@127.0.0.1   
      
   On Mon, 11 Jun 2012 06:32:56 -0700 (PDT), goran.pusic@gmail.com   
         wrote:   
   > int foo(const char* fname, ...)   
   > {   
   >    FILE* f = fopen(fname, ...);   
   >    if (!f) return EXIT_FAILURE;   
   >    if (!use(f), ...))   
   >    {   
   >      fclose(f); // This is "int fclose(...)"   
   >      return EXIT_FAILURE;   
   >   
   > fclose is declared as a can-fail operation, e.g. for the very reason   
   > you state in your file class example.   
   >   
   > So... How do you handle fclose failure? (Captain Obvious: current code   
   > does squat)   
      
   Hi   
      
   To me, the obvious thing to do is to read the man page, see what the   
   RETURN VALUES and the ERRORS are. In particular, if errno is EAGAIN or   
   EINTR, I would try to close the file again. Otherwise, what to do   
   depends on the error.   
      
   A+   
   Paul   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- 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