Title
More noexcept issues with filesystem operations
Status
c++20
Section
[fs.op.copy.file][fs.op.create.directories][fs.op.remove.all]
Submitter
Tim Song

Created on 2017-08-23.00:00:00 last changed 38 months ago

Messages

Date: 2018-03-18.16:03:30

Proposed resolution:

This wording is relative to N4687.

  1. Edit [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 [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 [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 [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: […]

Date: 2018-03-17.00:00:00

[ 2018-3-17 Adopted in Jacksonville ]

Date: 2017-11-09.15:13:04

[ 2017-11 Albuquerque Wednesday night issues processing ]

Moved to Ready

Date: 2017-08-23.00:00:00

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.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-03-18 16:03:30adminsetmessages: + msg9741
2018-03-18 16:03:30adminsetstatus: voting -> wp
2018-02-12 01:13:49adminsetstatus: ready -> voting
2017-11-09 15:13:04adminsetmessages: + msg9516
2017-11-09 15:13:04adminsetstatus: new -> ready
2017-08-27 13:39:11adminsetmessages: + msg9453
2017-08-23 00:00:00admincreate