Browse Source

truncate file when saving settings

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
03d037c197
  1. 1
      src/twister_utils.cpp

1
src/twister_utils.cpp

@ -71,6 +71,7 @@ int save_file(std::string const& filename, std::vector<char>& v)
libtorrent::error_code ec; libtorrent::error_code ec;
if (!f.open(filename, file::write_only, ec)) return -1; if (!f.open(filename, file::write_only, ec)) return -1;
if (ec) return -1; if (ec) return -1;
f.set_size(0, ec);
file::iovec_t b = {&v[0], v.size()}; file::iovec_t b = {&v[0], v.size()};
size_type written = f.writev(0, &b, 1, ec); size_type written = f.writev(0, &b, 1, ec);
if (written != int(v.size())) return -3; if (written != int(v.size())) return -3;

Loading…
Cancel
Save