diff --git a/include/config.cpp b/include/config.cpp index 05789efbb..0a1e06705 100755 --- a/include/config.cpp +++ b/include/config.cpp @@ -98,7 +98,10 @@ void TConfig::_write_paragraph( void TConfig::_write_file() { - ifstream in(_file); + if (_write_protected) + return; + + ifstream in(_file); TFilename temp; temp.temp("cnf"); ofstream out(temp); @@ -537,7 +540,8 @@ void TConfig::init( _file = fn; _paragraph = pa; _dirty = FALSE; - + _write_protected = FALSE; + if (!fexist(_file)) { if (warning) @@ -547,12 +551,12 @@ void TConfig::init( } if (_paragraph.blank()) - { + { TFilename name; HINSTANCE HInstance = (HINSTANCE)xvt_vobj_get_attr(NULL_WIN, ATTR_WIN_INSTANCE); GetModuleFileName(HInstance, name.get_buffer(), name.size()); _paragraph = name.name(); - _paragraph.cut(2); + _paragraph.cut(2); _paragraph.lower(); } @@ -606,8 +610,8 @@ TConfig::TConfig(int which_config, const char* paragraph) case CONFIG_DITTA: _file = firm2dir(prefix().get_codditta()); _file.add("prassid.ini"); - if (!fexist(_file)) - fcopy("prassid.ini", _file); + if (!fexist(_file)) + fcopy("prassid.ini", _file); break; case CONFIG_STUDIO: case CONFIG_USER: diff --git a/include/config.h b/include/config.h index dd208b42a..a538f99b1 100755 --- a/include/config.h +++ b/include/config.h @@ -56,6 +56,8 @@ class TConfig : public TObject TFilename _file; // @cmember:(INTERNAL) Indica se il paragrafo e' stato modificato (TRUE se esiste) bool _dirty; + // @cmember:(INTERNAL) Indica se proteggere il TConfig da scrittura + bool _write_protected; // @cmember:(INTERNAL) Indica se il paragrafo e' presente (TRUE se esiste) bool _ispresent; // @cmember:(INTERNAL) Nome del paragrafo attivo @@ -144,7 +146,13 @@ public: // @cmember Ritorna il nome del file di configurazione const TFilename& name() const { return _file; } - + + // @cmember Setta il valore del flag di protezione da scrittura + void write_protect(const bool b = TRUE) { _write_protected = b; } + + // @cmember Ritorna il valore del flag di protezione da scrittura + const bool is_write_protected() const { return _write_protected; } + // @cmember Costruttore (il paragrafo iniziale e' il modulo corrente // salvo diversa indicazione) TConfig(int which_config = CONFIG_GENERAL, const char* paragraph = NULL);