Boost logo

Boost :

From: Martin Adrian (adrianm_at_[hidden])
Date: 2006-03-10 02:27:45

1. The exception specifications are not clear
- All predicates (exists, is_*) will throw on errors but you need to look into
the status functions to see it.
- What happens if an error occurs while iteratoring a directory or when the
recursive iterator can't descend into a sub-folder.

2. Why not include the system_error code in the file_status object?

If you want to avoid exceptions with the currenct code you need to write code

system_error_code ec;
file_status f(status(p, ec));

if (exists(f) && is_directory(f))
else if (status_known(f))
  cout << "path is not a directory";
  cout << system_error_message(ec); // can't find this function in the TR2


// I don't care what the problem is.
system_error_code ec;
if (is_regular(status(p, ec)))

Which is kind of messy since the ec and f can't be scoped. It also seem
strange that you need to define a system_error_code variable just to avoid

With a file_status object defined as

struct file_status {
  explicit file_status(file_type v = status_unknown, system_error_code e = 0);
  file_type type() const;
  system_error_code error_code() const;
  std::string system_error_message() const;
  operator safe_bool() const { return ec == 0; }

the code can be written as:

if (file_status f(p, std::nothrow_t))
  if (exists(f) && is_directory(f))
    cout << "Path is not a directory";
  cout << f.system_error_message();


if (is_regular(status(p, std::nothrow_t)))

3. Why not differentiate storage type and interface type in the basic_path

Boost list run by bdawes at, gregod at, cpdaniel at, john at