473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Testing file deletion from under ostream object.

How would one go about testing for the deletion of a file that sits
under an o[f]stream object? I've tried is_open, good(), fail(), eof(),
bad() and catching exceptions - nothing! Aparently the << operator
still succeeds which I guess is because it's still writing to the
buffer (but even flush() doesn't fail). If an external program (such as
rm or del) deletes the physical file - how can I catch this in the
program? In a relatively elegant, non-hacky way!?

Regards,

Jim Vanns

Jun 8 '06 #1
2 1564
James Vanns wrote:
[...] If an external program (such
as rm or del) deletes the physical file - how can I catch this in the
program? In a relatively elegant, non-hacky way!?


There are no means for that in the language. C++ assumes a _single_thread_
_single_process_ execution environment for its definitions. Whatever your
OS allows you to do and the consequence of that is defined at the OS level.
Inter-process communication (and recognizing the deletion of an external
storage unit falls under that) should be asked about in a newsgroup for
your platform. See the FAQ for suggestions on that.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 8 '06 #2
James Vanns wrote:
How would one go about testing for the deletion of a file that sits
under an o[f]stream object?


There is no standard way to do that. On some operating systems, that can't
even happen, because files are not deleted as long as there are still some
references to them (including open file streams).

Jun 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sean W. Quinn | last post by:
Hey folks, I have a question regarding file handling, and the preservation of class structure. I have a class (and I will post snippets of code later in the post) with both primitive data...
16
by: Suzanne Vogel | last post by:
Hi, I've been trying to write a function to test whether one class is derived from another class. I am given only id's of the two classes. Therefore, direct use of template methods is not an...
6
by: radnoraj | last post by:
Hi, I am sucessfull in redirecting console output to a file. but in this case nothing is displayed on the console, cout output is written to file without display. how do write the output to...
0
by: AirYT | last post by:
Hello, Here's a quick explanation & problem: i have an ASP (iis v5.0) application that generates a pdf file and this file is saved to the server. it is saved in a location not available to web...
2
by: Seok Bee | last post by:
Dear Experts, In my web application, I am having a button to open a file located in the server. When I click on the button to view the file, I received the following error message:...
5
by: twiggy182 | last post by:
Hi, I really need you help because I'm not very familliar with ASP and I could not find any solution to my problem. To put you in situation, I have a CGI to which I send a file name, and that...
5
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, The following code was suggested by one of the users in this newsgroup when a pdf file was requested by a user from an asp page. I used the similar code in my page and the very interesting...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
4
by: gerardianlewis | last post by:
Any help appreciated. (VB.NET under XP and Vista, SP1 installed) My code, inherited from a VB6 version of an app that ran under W98, loads an image from a file into a PictureBox. The user may...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.