3014. More noexcept issues with filesystem operations

Section: 30.11.14.4 [fs.op.copy_file], 30.11.14.6 [fs.op.create_directories], 30.11.14.31 [fs.op.remove_all] Status: Ready Submitter: Tim Song Opened: 2017-08-23 Last modified: 2017-11-09

Priority: Not Prioritized

View other active issues in [fs.op.copy_file].

View all other issues in [fs.op.copy_file].

View all issues with Ready status.

Discussion:

create_directories may need to create temporary paths, and remove_all may need to create temporary paths and/or directory_iterators. These operations may require a potentially throwing memory allocation.

Implementations of copy_file may wish to dynamically allocate the buffer used for copying when the underlying OS doesn't supply a copy API directly. This can happen indirectly, e.g., by using <fstream> facilities to perform the copying without supplying a custom buffer. Unless LWG wishes to prohibit using a dynamically allocated buffer in this manner, the noexcept should be removed.

[2017-11 Albuquerque Wednesday night issues processing]

Moved to Ready

Proposed resolution:

This wording is relative to N4687.

  1. Edit 30.11.5 [fs.filesystem.syn], header <filesystem> synopsis, as indicated:

    namespace std::filesystem {
    
      […]
      
      bool copy_file(const path& from, const path& to);
      bool copy_file(const path& from, const path& to, error_code& ec) noexcept;
      bool copy_file(const path& from, const path& to, copy_options option);
      bool copy_file(const path& from, const path& to, copy_options option,
                     error_code& ec) noexcept;
    
      […]
    
      bool create_directories(const path& p);
      bool create_directories(const path& p, error_code& ec) noexcept;
      
      […]
      
      uintmax_t remove_all(const path& p);
      uintmax_t remove_all(const path& p, error_code& ec) noexcept;
      
      […]
    }
    
  2. Edit 30.11.14.4 [fs.op.copy_file] as indicated:

    bool copy_file(const path& from, const path& to);
    bool copy_file(const path& from, const path& to, error_code& ec) noexcept;
    

    -1- Returns: […]

    -2- Throws: […]

    bool copy_file(const path& from, const path& to, copy_options options);
    bool copy_file(const path& from, const path& to, copy_options options,
                   error_code& ec) noexcept;
    

    -3- Requires: […]

    -4- Effects: […]

    -5- Returns: […]

    -6- Throws: […]

    -7- Complexity: […]

  3. Edit 30.11.14.6 [fs.op.create_directories] as indicated:

    bool create_directories(const path& p);
    bool create_directories(const path& p, error_code& ec) noexcept;
    

    -1- Effects: […]

    -2- Postconditions: […]

    -3- Returns: […]

    -4- Throws: […]

    -5- Complexity: […]

  4. Edit 30.11.14.31 [fs.op.remove_all] as indicated:

    uintmax_t remove_all(const path& p);
    uintmax_t remove_all(const path& p, error_code& ec) noexcept;
    

    -1- Effects: […]

    -2- Postconditions: […]

    -3- Returns: […]

    -4- Throws: […]