[WIP] Wrap C++17 std::filesystem::path to solve encoding issue on Windows. #13195

pull ken2812221 wants to merge 5 commits into bitcoin:master from ken2812221:u8path changing 37 files +295 −225
  1. ken2812221 commented at 5:09 AM on May 9, 2018: contributor

    Fix #13103 We can call .u8string() everywhere and call .string() when we need to use native-encoded path.

  2. ken2812221 force-pushed on May 9, 2018
  3. ken2812221 force-pushed on May 9, 2018
  4. laanwj commented at 5:36 AM on May 9, 2018: member

    Neat. Concept ACK!

  5. fanquake added the label Utils/log/libs on May 9, 2018
  6. ken2812221 force-pushed on May 9, 2018
  7. fanquake commented at 6:14 AM on May 9, 2018: member

    Travis macOS build failed with:

    In file included from util.cpp:6:
    In file included from ./util.h:18:
    In file included from ./fs.h:11:
    In file included from /home/travis/build/bitcoin/bitcoin/depends/x86_64-apple-darwin11/share/../include/boost/filesystem.hpp:16:
    /home/travis/build/bitcoin/bitcoin/depends/x86_64-apple-darwin11/share/../include/boost/filesystem/path.hpp:141:33: error: no type named 'type' in 'boost::enable_if<boost::filesystem::path_traits::is_pathable<Path>, void>'; 'enable_if' cannot be used to disable this declaration
          typename boost::enable_if<path_traits::is_pathable<
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
    ./util.h:315:36: note: in instantiation of member function 'boost::filesystem::path::path' requested here
        using boost::filesystem::path::path;
                                       ^
    util.cpp:1098:12: note: while substituting deduced template arguments into function template 'Path' [with Source = Path]
        return Path(Utf8ToNative(source));
               ^
    1 error generated.
    
  8. ken2812221 force-pushed on May 9, 2018
  9. ken2812221 force-pushed on May 9, 2018
  10. ken2812221 force-pushed on May 9, 2018
  11. ken2812221 force-pushed on May 9, 2018
  12. ken2812221 force-pushed on May 9, 2018
  13. in src/util.h:312 in 14a2574690 outdated
     308 | @@ -309,4 +309,13 @@ std::unique_ptr<T> MakeUnique(Args&&... args)
     309 |   */
     310 |  int ScheduleBatchPriority(void);
     311 |  
     312 | +class Path : public boost::filesystem::path
    


    laanwj commented at 8:15 AM on May 9, 2018:

    Would be better in src/fs.h?

  14. in src/util.cpp:1026 in 14a2574690 outdated
    1021 | @@ -1020,3 +1022,45 @@ int ScheduleBatchPriority(void)
    1022 |      return 1;
    1023 |  #endif
    1024 |  }
    1025 | +
    1026 | +static std::string NativeToUtf8(const std::string& source)
    


    laanwj commented at 8:16 AM on May 9, 2018:

    string encoding should probably be in utilstrencodings.[ch]

  15. laanwj requested review from theuni on May 9, 2018
  16. laanwj commented at 8:25 AM on May 9, 2018: member

    Fix #13103

    How does this fix that issue? This adds a class and some functions, but never uses them, or am I missing something?

    We can call .u8string() everywhere and call .string() when we need to use native-encoded path.

    Concept ACK, though I'm not entirely convinced on wrapping versus using functions where needed.

  17. ken2812221 commented at 8:34 AM on May 9, 2018: contributor

    I'm trying to re-do #13107 with pretty code, but it's still WIP. The target is to fix #13103

  18. ken2812221 force-pushed on May 9, 2018
  19. ken2812221 force-pushed on May 9, 2018
  20. ken2812221 force-pushed on May 9, 2018
  21. ken2812221 force-pushed on May 9, 2018
  22. ken2812221 force-pushed on May 9, 2018
  23. ken2812221 force-pushed on May 9, 2018
  24. ken2812221 force-pushed on May 9, 2018
  25. ken2812221 force-pushed on May 9, 2018
  26. [WIP] Wrap C++17 std::filesystem::path to solve encoding issue on Windows 641517d8e9
  27. scripted-diff: Use fsbridge::Path instead of boost::filesystem::path
    -BEGIN VERIFY SCRIPT-
    sed -i 's/fs::path/fsbridge::Path/g' $(git grep --name-only 'fs::path' -- '*.cpp' '*.h' | grep -v 'fs.h' | grep -v 'fs.cpp')
    sed -i 's/boost::filesystem::path/fsbridge::Path/g' $(git grep --name-only 'boost::filesystem::path' -- '*.cpp' '*.h' | grep -v 'fs.h' | grep -v 'fs.cpp')
    -END VERIFY SCRIPT-
    d98cc4eaa8
  28. Move fs::path(string) to fsbridge::U8Path(string) a492285b49
  29. ken2812221 force-pushed on May 9, 2018
  30. Read command line arguments as utf8 d37d4b2835
  31. scripted-diff: Use `.u8string()` instead of `.string()`
    -BEGIN VERIFY SCRIPT-
    sed -i 's/\.string()/\.u8string()/g' $(git grep --name-only '\.string()' -- '*.cpp' '*.h' | grep -v 'fs.h' | grep -v 'fs.cpp')
    -END VERIFY SCRIPT-
    02fb8835ba
  32. ken2812221 force-pushed on May 9, 2018
  33. ken2812221 commented at 11:59 PM on May 9, 2018: contributor

    Seems not possible to wrap all filesystem classes. Close it and reopen #13107

  34. ken2812221 closed this on May 9, 2018

  35. ken2812221 deleted the branch on May 9, 2018
  36. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me