[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master f3d0aad 2/3: Avoid writing a zero-byte '.past
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master f3d0aad 2/3: Avoid writing a zero-byte '.pasted_out.tsv' file |
Date: |
Fri, 15 Jun 2018 13:52:07 -0400 (EDT) |
branch: master
commit f3d0aadb6315c840deab244e5ff49fc992011802
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Avoid writing a zero-byte '.pasted_out.tsv' file
Reordered a few lines of code, so that no file is created until it is
known that it will actually be written to.
---
census_view.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/census_view.cpp b/census_view.cpp
index 8e792c8..9f9e707 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -1793,12 +1793,6 @@ void CensusView::UponPasteCensusOut(wxCommandEvent&)
void CensusView::DoPasteCensusOut() const
{
- configurable_settings const& c = configurable_settings::instance();
- std::string const& e = c.spreadsheet_file_extension();
- std::string const f = fs::basename(base_filename()) + ".pasted_out.cns";
- std::string file_name = unique_filepath(f, e).string();
- std::ofstream os(file_name.c_str(), ios_out_app_binary());
-
std::vector<std::string> distinct_headers;
std::vector<std::string> const&
all_headers(case_parms()[0].member_names());
for(auto const& header : all_headers)
@@ -1815,6 +1809,12 @@ void CensusView::DoPasteCensusOut() const
alarum() << "All cells identical: nothing to paste out." << LMI_FLUSH;
}
+ configurable_settings const& c = configurable_settings::instance();
+ std::string const& e = c.spreadsheet_file_extension();
+ std::string const f = fs::basename(base_filename()) + ".pasted_out.cns";
+ std::string file_name = unique_filepath(f, e).string();
+ std::ofstream os(file_name.c_str(), ios_out_app_binary());
+
for(auto const& header : distinct_headers)
{
os << header << '\t';