From 7c26664d174a564eb7655ede1a015a3e17882363 Mon Sep 17 00:00:00 2001 From: luca Date: Wed, 1 Jun 2011 14:19:19 +0000 Subject: [PATCH] Patch level :10.0 Files correlati : Ricompilazione Demo : [ ] Commento : la save_as deve ritornare false se non riesce il salvataggio git-svn-id: svn://10.65.10.50/branches/R_10_00@22205 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/recset.cpp | 16 +++++++++++++--- include/textset.cpp | 24 +++++++++++++++++------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/include/recset.cpp b/include/recset.cpp index a3de0e671..05279899c 100755 --- a/include/recset.cpp +++ b/include/recset.cpp @@ -98,8 +98,12 @@ const TToken_string& TRecordset::sheet_head() const bool TRecordset::save_as_html(const char* path) { - TProgind pi(items(), TR("Esportazione in corso..."), true, true); ofstream out(path); + if (out.fail()) + return false; + + TProgind pi(items(), TR("Esportazione in corso..."), true, true); + out << "" << endl; save_html_head(out, main_app().title()); out << "" << endl; @@ -231,9 +235,12 @@ bool TRecordset::save_as_html(const char* path) bool TRecordset::save_as_text(const char* path) { + ofstream out(path); + if (out.fail()) + return false; + TProgind pi(items(), TR("Esportazione in corso..."), true, true); - ofstream out(path); TString val; const char sep = text_separator(); const bool as400 = (sep == ' '); @@ -288,9 +295,12 @@ bool TRecordset::save_as_text(const char* path) bool TRecordset::save_as_campo(const char* path) { - TProgind pi(items(), TR("Esportazione in corso..."), true, true); ofstream out(path); + if (out.fail()) + return false; + TProgind pi(items(), TR("Esportazione in corso..."), true, true); + out << "[Head]" << endl; out << "Version=0"; diff --git a/include/textset.cpp b/include/textset.cpp index c7c2b2e9e..b000a2de8 100755 --- a/include/textset.cpp +++ b/include/textset.cpp @@ -186,14 +186,19 @@ bool TText_recordset::exec(const char* query) bool TText_recordset::save_as_text(const char* path) { - bool ok = path && *path; - if (ok) + bool valid = path && *path; + if (valid) { ofstream out(path); - for (bool ok = move_first(); ok; ok = move_next()) - out << row() << endl; + if (out.good()) + { + for (bool ok = move_first(); ok; ok = move_next()) + out << row() << endl; + } + else + valid = false; } - return ok; + return valid; } bool TText_recordset::save_as(const char* path, TRecordsetExportFormat fmt) @@ -685,8 +690,13 @@ bool TAS400_recordset::save_as_text(const char* path) if (valid) { ofstream out(path, ios::binary); - for (bool ok = move_first(); ok; ok = move_next()) - out << row(); // NON mettere << endl + if (out.good()) + { + for (bool ok = move_first(); ok; ok = move_next()) + out << row(); // NON mettere << endl + } + else + valid = false; } return valid; }