Jack Klein <ja*******@spam cop.net> wrote:
On some platforms, a single file may have
more than one name.
.... or none at all:
std::ofstream tmpfile("mytemp file");
std::remove("my tempfile");
This is fine eg. on POSIX platforms and, except for the use of the hardcoded
name, a pretty common technique to create temporary files which are to be
removed when the program dies for whatever reason.
Of course you could always build an object that contained a
std::string with the name and a stream reference.
.... or attach the name to your file object:
int const index = std::ios_base:: xalloc();
std::string filename("file. name");
std::ofstream file(filename.c _str());
file.pword(inde x) = const_cast<char *>(filename.c_s tr());
// ...
char const* name = static_cast<cha r*>(file.pword( index));
--
<mailto:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
Phaidros eaSE - Easy Software Engineering: <http://www.phaidros.co m/>