Page MenuHome

Use existing C-APIs for path and filesystem handling
ClosedPublic

Authored by Julian Eisel (Severin) on Sep 17 2021, 12:51 PM.

Details

Summary

The ghc::filesystem we wanted to use for a platform compatible replacement of
std::filesystem (see D12197) doesn't behave as we expect or want to. We could
probably find a solution, but it's not worth the extra time. To move this
forward, we can switch the asset catalogs to use Blender's C functions for path
and filesystem handling.

Diff Detail

Repository
rB Blender
Branch
temp-asset-browser-catalogs-c-filestuff (branched from master)
Build Status
Buildable 17156
Build 17156: arc lint + arc unit

Event Timeline

Julian Eisel (Severin) requested review of this revision.Sep 17 2021, 12:51 PM
Julian Eisel (Severin) created this revision.
source/blender/blenkernel/intern/asset_catalog.cc
80

We could just use const char * only, but I prefer passing around StringRefs, even if we have to use .data() a lot.

source/blender/blenkernel/intern/asset_catalog_test.cc
50

Note that BKE_tempdir_session() explicitly states that it has a trailing slash. So if the path is empty, concatenating with a / would result in /test-temporary-path. Think the std::filesystem::path::operator/() made sure a relative path doesn't become absolute because the parent is empty.

Julian Eisel (Severin) updated this revision to Diff 42096.EditedSep 20 2021, 5:04 PM
  • Use StringRefNull to avoid pitfalls with non-terminated strings

The previous code using StringRef was fine logically, but I rather be explicit about what's expected to avoid errors when the code changes.

Correct base branch...

  • Partially revert previous update

Thought the used StringRefNull constructor could construct a new,
null-terminated string. Of course that's wrong since it's a non owning type.

  • Update to changes in base branch, use c_str() not data() for std::string
  • Something went wrong with the merge that confused arc, trying again...
This revision is now accepted and ready to land.Sep 21 2021, 3:54 PM

This is merged into the temp-asset-browser-catalogs branch now, which will be merged into master soon.

Think I wanted to close this earlier :)