Page MenuHomePhabricator

convert unsafe fs::path std::string conversion calls [1/7]
ClosedPublic

Authored by PiRK on Jan 10 2022, 12:51.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC21a1f1ba22e6: convert unsafe fs::path std::string conversion calls [1/7]
Summary

There is no change in behavior. This just helps prepare for the
transition from boost::filesystem to std::filesystem by avoiding calls
to methods which will be unsafe after the transaction to std::filesystem
to due lack of a boost::filesystem::path::imbue equivalent and inability
to set a predictable locale.

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Co-authored-by: Kiminuo <kiminuo@protonmail.com>
Co-authored-by: MarcoFalke <falke.marco@gmail.com>

This is a partial backport of core#22937 [2a/2g]
https://github.com/bitcoin/bitcoin/pull/22937/commits/6544ea5035268025207d2402db2f7d90fde947a6

The backport for this commit was split in to multiple commits to make review easier.

This first commit does mainly two things:

  • add a couple of necessary methods to fs::path: quoted and operator+ to be used in subsequent commits to migrate away from methods that will be unsafe when we will transition from boost::filesystem to std::filesystem.
  • use fs::ofstream instead of std::ostream because the former defines a constructor for fs::path, and pass in fs::path directly when constructing fs::ofstream instead of a c string. This removes the need to to path to string conversions that depend on the the BOOST version.

Depends on D10784, D10781, D10783

Test Plan

ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Jan 10 2022, 12:51
PiRK retitled this revision from convert unsafe fs::path std::string conversion calls to convert unsafe fs::path std::string conversion calls [1/7].Jan 10 2022, 12:53
This revision is now accepted and ready to land.Jan 11 2022, 09:33