From 04a0a8edcff3073c5cecddcba36cdff46333337c Mon Sep 17 00:00:00 2001 From: angelo Date: Thu, 11 Sep 1997 14:39:04 +0000 Subject: [PATCH] Correzioni alla apertura del file in lettura. Aggiunta delete nel distruttore. git-svn-id: svn://10.65.10.50/trunk@5187 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/filetext.cpp | 15 +++++++++++++-- include/filetext.h | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/filetext.cpp b/include/filetext.cpp index 62015e61b..7f5a74d94 100755 --- a/include/filetext.cpp +++ b/include/filetext.cpp @@ -249,6 +249,14 @@ TFile_text::TFile_text(const char* file_name, const char* config_name) } } } + +TFile_text::~TFile_text() +{ + if (_read_file) + delete _read_file; + if (_write_file) + delete _write_file; +} //Scrive su file il record_text (valido anche per header e footer) int TFile_text::write(TRecord_text& rec) @@ -559,9 +567,12 @@ int TFile_text::open(char mode) if (_read_file) delete _read_file; - _read_file = new ifstream(_name, ios::binary); + _read_file = new ifstream(_name, ios::binary | ios::nocreate); if (!ok_r()) - error_box("Impossibile aprire il file %s in lettura", (const char *)_name); + { + error_box("Impossibile aprire il file %s in lettura", (const char *)_name); + return _read_file->rdstate() != ios::goodbit; + } } if (mode == 'w')//apertura in scrittura { diff --git a/include/filetext.h b/include/filetext.h index cd392dd3b..dbee96ca3 100755 --- a/include/filetext.h +++ b/include/filetext.h @@ -136,7 +136,7 @@ protected: public: TFile_text(const char* file_name, const char* config_name); - virtual ~TFile_text(){} + virtual ~TFile_text(); ifstream* read_file() {return _read_file;} ofstream* write_file() {return _write_file;} void set_gen_parm(TConfig& config, const TString& section);//scarica i parametri generali dal file di configurazione