Project

General

Profile

Actions

Bug #5341

closed

ndn::io::save does not complain if output file cannot be created

Added by Davide Pesavento over 1 year ago. Updated 9 days ago.

Status:
Closed
Priority:
Normal
Category:
Utils
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:

Description

The documentation of ndn::io::save(T, std::string) states that ndn::io::Error is raised in case of "error during encoding or saving". However, if the output file cannot be created for whatever reason (e.g., insufficient permissions, nonexistent parent directory), no error is raised and there is no indication to the caller that the function invocation failed.

Actions #1

Updated by Davide Pesavento 12 days ago

  • Status changed from New to In Progress
  • Assignee set to Davide Pesavento
  • Target version set to 0.9.1

I plan to remove this function altogether.

Actions #2

Updated by Davide Pesavento 9 days ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

https://gerrit.named-data.net/c/ndn-cxx/+/7865

The save(const T& obj, const std::string& filename) wrapper is deprecated and will be removed without replacement. It saves one line of code at the call site while complicating error handling, because different callers may have vastly different needs in this regard. So it doesn't make much sense to maintain this in the library.

The other overload, save(const T& obj, std::ostream& os), is deprecated in favor of saveTlv(). The latter is more consistent with loadTlv().

loadBuffer() and saveBuffer() have improved error handling. Specifically, they will throw io::Error if the stream is in a bad state before reading or after writing.

Actions

Also available in: Atom PDF