RSS Forums RSS
Please support our C++ advertiser: Programming Forums

ofstream - detect if file has been deleted between open and close

Join Date: Aug 2003
Location: Austin, TX
Posts: 117
Reputation: subtronic is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 0
subtronic's Avatar
subtronic subtronic is offline Offline
Junior Poster

Re: ofstream - detect if file has been deleted between open and close

  #2  
May 8th, 2005
Originally Posted by winbatch
As seen in another thread, I'm working on a Log class. I'm running into an issue that if I delete the file that's being written to, the Log class doesn't detect it and continues to 'think' it's writing even though the file is gone... (Note that this is on sun solaris in case it matters)

I've tried the following to try and detect this
(assuming my ofstream is named out)
!out.is_open()
!out.good()
out.fail()

None of them seem to detect this issue. (Nor changing the permissions to non-write while the file has already been opened by the app). Note that these functions DO catch a problem with opening the file, but not when it's already opened. Any advice?

Why not close the file descriptor?
Reply With Quote  
All times are GMT -4. The time now is 3:08 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC