Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Apr 23, 2019

Boost Filesystem basename() and extension() functions are deprecated since v1.36.0.

See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

Also this PR prevents further use of deprecated Boost Filesystem functions.
Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

Note: On my Linux system Boost 1.65.1 header /usr/include/boost/filesystem/convenience.hpp contains:

# ifndef BOOST_FILESYSTEM_NO_DEPRECATED

    inline std::string extension(const path & p)
    {
      return p.extension().string();
    }

    inline std::string basename(const path & p)
    {
      return p.stem().string();
    }

    inline path change_extension( const path & p, const path & new_extension )
    { 
      path new_p( p );
      new_p.replace_extension( new_extension );
      return new_p;
    }

# endif

UPDATE:
Also removed unused code as noted by ryanofsky.

@hebasto hebasto force-pushed the 20190423-boost-coding-guidelines branch from e5ce5a1 to 8823a11 Compare April 29, 2019 08:56
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 8823a11

@hebasto hebasto force-pushed the 20190423-boost-coding-guidelines branch from 8823a11 to 276a674 Compare April 29, 2019 18:49
@hebasto
Copy link
Member Author

hebasto commented Apr 29, 2019

@ryanofsky
Thank you for your review. Your comment has been addressed.
Would you mind re-reviewing?

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 276a674. Only change is replacing impossible to reach condition with an assert.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 276a674.

Shouldn't 3edc716 be after 276a674?

errorStr = strprintf(_("Wallet %s resides outside wallet directory %s"), walletFile, walletDir.string());
return false;
}
assert(walletFile == fs::path(walletFile).filename().string());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion, either drop the assertion (GetWalletEnv always returns a plain filename) or make it complete because:

std::cout << path("/").filename();            // outputs "/"
std::cout << path(".").filename();            // outputs "."
std::cout << path("..").filename();           // outputs ".."

so for these cases the assertion passes.

SplitWalletPath() garanties the walletFile is a plain filename without a
directory.
@hebasto hebasto force-pushed the 20190423-boost-coding-guidelines branch from 276a674 to 8d0add4 Compare April 29, 2019 21:55
@hebasto
Copy link
Member Author

hebasto commented Apr 29, 2019

@promag thank you for your review.

Your comments have been addressed:

  • the assertion has been dropped
  • commits have been rearranged

@promag
Copy link
Contributor

promag commented Apr 29, 2019

utACK 8d0add4.

@Empact
Copy link
Contributor

Empact commented Apr 30, 2019

utACK 8d0add4 could squash the latter two

The test was introduced in #7691 fyi, seems fine to remove.

Boost Filesystem basename() function is deprecated since v1.36.0.
Also, defining BOOST_FILESYSTEM_NO_DEPRECATED before including
filesystem headers is strongly recommended. This prevents inadvertent
use of old features, particularly legacy function names, that have been
replaced and are going to go away in the future.
@hebasto hebasto force-pushed the 20190423-boost-coding-guidelines branch from 8d0add4 to a0a222e Compare April 30, 2019 07:07
@hebasto
Copy link
Member Author

hebasto commented Apr 30, 2019

@Empact

utACK 8d0add4 could squash the latter two

Done.

The test was introduced in #7691 fyi, seems fine to remove.

I guess it was earlier in #1889 ;)

@Empact
Copy link
Contributor

Empact commented Apr 30, 2019

utACK a0a222e

I guess it was earlier in #1889 ;)

Indeed! :P

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK a0a222e. Only change is dropping assert and squashing first two commits.

@practicalswift
Copy link
Contributor

utACK a0a222e

@fanquake
Copy link
Member

fanquake commented May 8, 2019

utACK a0a222e

@meshcollider
Copy link
Contributor

utACK a0a222e

@meshcollider meshcollider merged commit a0a222e into bitcoin:master May 8, 2019
meshcollider added a commit that referenced this pull request May 8, 2019
…m functions

a0a222e Replace deprecated Boost Filesystem function (Hennadii Stepanov)
4f65af9 Remove dead code for walletFile check (Hennadii Stepanov)

Pull request description:

  Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions).

  See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

  Also this PR prevents further use of deprecated Boost Filesystem functions.
  Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

  Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains:
  ```c++
  # ifndef BOOST_FILESYSTEM_NO_DEPRECATED

      inline std::string extension(const path & p)
      {
        return p.extension().string();
      }

      inline std::string basename(const path & p)
      {
        return p.stem().string();
      }

      inline path change_extension( const path & p, const path & new_extension )
      {
        path new_p( p );
        new_p.replace_extension( new_extension );
        return new_p;
      }

  # endif
  ```

  UPDATE:
  Also removed unused code as [noted](#15880 (comment)) by **ryanofsky**.

ACKs for commit a0a222:
  Empact:
    utACK a0a222e
  practicalswift:
    utACK a0a222e
  fanquake:
    utACK a0a222e
  ryanofsky:
    utACK a0a222e. Only change is dropping assert and squashing first two commits.

Tree-SHA512: bc54355441c49957507eb8d3a5782b92d65674504d69779bc16b1b997b2e7424d5665eb6bfb6e10b430a6cacd2aca70af2f94e5f7f10bea24624202834ad35c7
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 8, 2019
…lesystem functions

a0a222e Replace deprecated Boost Filesystem function (Hennadii Stepanov)
4f65af9 Remove dead code for walletFile check (Hennadii Stepanov)

Pull request description:

  Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions).

  See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

  Also this PR prevents further use of deprecated Boost Filesystem functions.
  Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

  Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains:
  ```c++
  # ifndef BOOST_FILESYSTEM_NO_DEPRECATED

      inline std::string extension(const path & p)
      {
        return p.extension().string();
      }

      inline std::string basename(const path & p)
      {
        return p.stem().string();
      }

      inline path change_extension( const path & p, const path & new_extension )
      {
        path new_p( p );
        new_p.replace_extension( new_extension );
        return new_p;
      }

  # endif
  ```

  UPDATE:
  Also removed unused code as [noted](bitcoin#15880 (comment)) by **ryanofsky**.

ACKs for commit a0a222:
  Empact:
    utACK bitcoin@a0a222e
  practicalswift:
    utACK a0a222e
  fanquake:
    utACK a0a222e
  ryanofsky:
    utACK a0a222e. Only change is dropping assert and squashing first two commits.

Tree-SHA512: bc54355441c49957507eb8d3a5782b92d65674504d69779bc16b1b997b2e7424d5665eb6bfb6e10b430a6cacd2aca70af2f94e5f7f10bea24624202834ad35c7
@hebasto hebasto deleted the 20190423-boost-coding-guidelines branch May 9, 2019 07:13
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 4, 2020
…stem functions

Summary:
Replace deprecated Boost Filesystem function (Hennadii Stepanov)
Remove dead code for walletFile check (Hennadii Stepanov)

Pull request description:

  Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions).

  See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

  Also this PR prevents further use of deprecated Boost Filesystem functions.
  Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

  Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains:
  ```c++
  # ifndef BOOST_FILESYSTEM_NO_DEPRECATED

      inline std::string extension(const path & p)
      {
        return p.extension().string();
      }

      inline std::string basename(const path & p)
      {
        return p.stem().string();
      }

      inline path change_extension( const path & p, const path & new_extension )
      {
        path new_p( p );
        new_p.replace_extension( new_extension );
        return new_p;
      }

  # endif
  ```

  UPDATE:
  Also removed unused code as [noted](bitcoin/bitcoin#15880 (comment)) by **ryanofsky**.

---

Backport of Core [[bitcoin/bitcoin#15880 | PR15880]] and [[bitcoin/bitcoin#17654 | PR17654]] (to unbreak PR15880)

Test Plan:
  ninja check check-functional

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7362
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 27, 2021
…lesystem functions

a0a222e Replace deprecated Boost Filesystem function (Hennadii Stepanov)
4f65af9 Remove dead code for walletFile check (Hennadii Stepanov)

Pull request description:

  Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions).

  See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

  Also this PR prevents further use of deprecated Boost Filesystem functions.
  Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

  Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains:
  ```c++
  # ifndef BOOST_FILESYSTEM_NO_DEPRECATED

      inline std::string extension(const path & p)
      {
        return p.extension().string();
      }

      inline std::string basename(const path & p)
      {
        return p.stem().string();
      }

      inline path change_extension( const path & p, const path & new_extension )
      {
        path new_p( p );
        new_p.replace_extension( new_extension );
        return new_p;
      }

  # endif
  ```

  UPDATE:
  Also removed unused code as [noted](bitcoin#15880 (comment)) by **ryanofsky**.

ACKs for commit a0a222:
  Empact:
    utACK bitcoin@a0a222e
  practicalswift:
    utACK a0a222e
  fanquake:
    utACK a0a222e
  ryanofsky:
    utACK a0a222e. Only change is dropping assert and squashing first two commits.

Tree-SHA512: bc54355441c49957507eb8d3a5782b92d65674504d69779bc16b1b997b2e7424d5665eb6bfb6e10b430a6cacd2aca70af2f94e5f7f10bea24624202834ad35c7
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 28, 2021
…lesystem functions

a0a222e Replace deprecated Boost Filesystem function (Hennadii Stepanov)
4f65af9 Remove dead code for walletFile check (Hennadii Stepanov)

Pull request description:

  Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions).

  See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

  Also this PR prevents further use of deprecated Boost Filesystem functions.
  Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

  Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains:
  ```c++
  # ifndef BOOST_FILESYSTEM_NO_DEPRECATED

      inline std::string extension(const path & p)
      {
        return p.extension().string();
      }

      inline std::string basename(const path & p)
      {
        return p.stem().string();
      }

      inline path change_extension( const path & p, const path & new_extension )
      {
        path new_p( p );
        new_p.replace_extension( new_extension );
        return new_p;
      }

  # endif
  ```

  UPDATE:
  Also removed unused code as [noted](bitcoin#15880 (comment)) by **ryanofsky**.

ACKs for commit a0a222:
  Empact:
    utACK bitcoin@a0a222e
  practicalswift:
    utACK a0a222e
  fanquake:
    utACK a0a222e
  ryanofsky:
    utACK a0a222e. Only change is dropping assert and squashing first two commits.

Tree-SHA512: bc54355441c49957507eb8d3a5782b92d65674504d69779bc16b1b997b2e7424d5665eb6bfb6e10b430a6cacd2aca70af2f94e5f7f10bea24624202834ad35c7
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 29, 2021
…lesystem functions

a0a222e Replace deprecated Boost Filesystem function (Hennadii Stepanov)
4f65af9 Remove dead code for walletFile check (Hennadii Stepanov)

Pull request description:

  Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions).

  See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

  Also this PR prevents further use of deprecated Boost Filesystem functions.
  Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

  Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains:
  ```c++
  # ifndef BOOST_FILESYSTEM_NO_DEPRECATED

      inline std::string extension(const path & p)
      {
        return p.extension().string();
      }

      inline std::string basename(const path & p)
      {
        return p.stem().string();
      }

      inline path change_extension( const path & p, const path & new_extension )
      {
        path new_p( p );
        new_p.replace_extension( new_extension );
        return new_p;
      }

  # endif
  ```

  UPDATE:
  Also removed unused code as [noted](bitcoin#15880 (comment)) by **ryanofsky**.

ACKs for commit a0a222:
  Empact:
    utACK bitcoin@a0a222e
  practicalswift:
    utACK a0a222e
  fanquake:
    utACK a0a222e
  ryanofsky:
    utACK a0a222e. Only change is dropping assert and squashing first two commits.

Tree-SHA512: bc54355441c49957507eb8d3a5782b92d65674504d69779bc16b1b997b2e7424d5665eb6bfb6e10b430a6cacd2aca70af2f94e5f7f10bea24624202834ad35c7
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
…lesystem functions

a0a222e Replace deprecated Boost Filesystem function (Hennadii Stepanov)
4f65af9 Remove dead code for walletFile check (Hennadii Stepanov)

Pull request description:

  Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions).

  See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

  Also this PR prevents further use of deprecated Boost Filesystem functions.
  Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

  Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains:
  ```c++
  # ifndef BOOST_FILESYSTEM_NO_DEPRECATED

      inline std::string extension(const path & p)
      {
        return p.extension().string();
      }

      inline std::string basename(const path & p)
      {
        return p.stem().string();
      }

      inline path change_extension( const path & p, const path & new_extension )
      {
        path new_p( p );
        new_p.replace_extension( new_extension );
        return new_p;
      }

  # endif
  ```

  UPDATE:
  Also removed unused code as [noted](bitcoin#15880 (comment)) by **ryanofsky**.

ACKs for commit a0a222:
  Empact:
    utACK bitcoin@a0a222e
  practicalswift:
    utACK a0a222e
  fanquake:
    utACK a0a222e
  ryanofsky:
    utACK a0a222e. Only change is dropping assert and squashing first two commits.

Tree-SHA512: bc54355441c49957507eb8d3a5782b92d65674504d69779bc16b1b997b2e7424d5665eb6bfb6e10b430a6cacd2aca70af2f94e5f7f10bea24624202834ad35c7
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
…lesystem functions

a0a222e Replace deprecated Boost Filesystem function (Hennadii Stepanov)
4f65af9 Remove dead code for walletFile check (Hennadii Stepanov)

Pull request description:

  Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions).

  See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

  Also this PR prevents further use of deprecated Boost Filesystem functions.
  Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

  Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains:
  ```c++
  # ifndef BOOST_FILESYSTEM_NO_DEPRECATED

      inline std::string extension(const path & p)
      {
        return p.extension().string();
      }

      inline std::string basename(const path & p)
      {
        return p.stem().string();
      }

      inline path change_extension( const path & p, const path & new_extension )
      {
        path new_p( p );
        new_p.replace_extension( new_extension );
        return new_p;
      }

  # endif
  ```

  UPDATE:
  Also removed unused code as [noted](bitcoin#15880 (comment)) by **ryanofsky**.

ACKs for commit a0a222:
  Empact:
    utACK bitcoin@a0a222e
  practicalswift:
    utACK a0a222e
  fanquake:
    utACK a0a222e
  ryanofsky:
    utACK a0a222e. Only change is dropping assert and squashing first two commits.

Tree-SHA512: bc54355441c49957507eb8d3a5782b92d65674504d69779bc16b1b997b2e7424d5665eb6bfb6e10b430a6cacd2aca70af2f94e5f7f10bea24624202834ad35c7
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 8, 2021
…lesystem functions

a0a222e Replace deprecated Boost Filesystem function (Hennadii Stepanov)
4f65af9 Remove dead code for walletFile check (Hennadii Stepanov)

Pull request description:

  Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions).

  See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

  Also this PR prevents further use of deprecated Boost Filesystem functions.
  Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

  Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains:
  ```c++
  # ifndef BOOST_FILESYSTEM_NO_DEPRECATED

      inline std::string extension(const path & p)
      {
        return p.extension().string();
      }

      inline std::string basename(const path & p)
      {
        return p.stem().string();
      }

      inline path change_extension( const path & p, const path & new_extension )
      {
        path new_p( p );
        new_p.replace_extension( new_extension );
        return new_p;
      }

  # endif
  ```

  UPDATE:
  Also removed unused code as [noted](bitcoin#15880 (comment)) by **ryanofsky**.

ACKs for commit a0a222:
  Empact:
    utACK bitcoin@a0a222e
  practicalswift:
    utACK a0a222e
  fanquake:
    utACK a0a222e
  ryanofsky:
    utACK a0a222e. Only change is dropping assert and squashing first two commits.

Tree-SHA512: bc54355441c49957507eb8d3a5782b92d65674504d69779bc16b1b997b2e7424d5665eb6bfb6e10b430a6cacd2aca70af2f94e5f7f10bea24624202834ad35c7
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 10, 2021
…lesystem functions

a0a222e Replace deprecated Boost Filesystem function (Hennadii Stepanov)
4f65af9 Remove dead code for walletFile check (Hennadii Stepanov)

Pull request description:

  Boost Filesystem `basename()` and `extension()` functions are [deprecated since v1.36.0](https://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Convenience-functions).

  See more: https://lists.boost.org/Archives/boost/2010/01/160905.php

  Also this PR prevents further use of deprecated Boost Filesystem functions.
  Ref: https://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm#Coding-guidelines

  Note: On my Linux system Boost 1.65.1 header `/usr/include/boost/filesystem/convenience.hpp` contains:
  ```c++
  # ifndef BOOST_FILESYSTEM_NO_DEPRECATED

      inline std::string extension(const path & p)
      {
        return p.extension().string();
      }

      inline std::string basename(const path & p)
      {
        return p.stem().string();
      }

      inline path change_extension( const path & p, const path & new_extension )
      {
        path new_p( p );
        new_p.replace_extension( new_extension );
        return new_p;
      }

  # endif
  ```

  UPDATE:
  Also removed unused code as [noted](bitcoin#15880 (comment)) by **ryanofsky**.

ACKs for commit a0a222:
  Empact:
    utACK bitcoin@a0a222e
  practicalswift:
    utACK a0a222e
  fanquake:
    utACK a0a222e
  ryanofsky:
    utACK a0a222e. Only change is dropping assert and squashing first two commits.

Tree-SHA512: bc54355441c49957507eb8d3a5782b92d65674504d69779bc16b1b997b2e7424d5665eb6bfb6e10b430a6cacd2aca70af2f94e5f7f10bea24624202834ad35c7
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants