Skip to content

[core] Refactor ecal_path_processing.cpp to C++17 std::filesystem#2608

Merged
Peguen merged 7 commits intomasterfrom
feature/path_processing_to_cpp17
May 5, 2026
Merged

[core] Refactor ecal_path_processing.cpp to C++17 std::filesystem#2608
Peguen merged 7 commits intomasterfrom
feature/path_processing_to_cpp17

Conversation

@Peguen
Copy link
Copy Markdown
Contributor

@Peguen Peguen commented Apr 10, 2026

Description

Replaces the custom EcalUtils::Filesystem / EcalUtils::String wrappers in ecal_path_processing.cpp with standard C++17 <filesystem> equivalents and fixes several bugs found during the review.

@Peguen Peguen added cherry-pick-to-support/v6.0 Cherry pick these changes to support/v6.0 cherry-pick-to-support/v6.1 Cherry pick these changes to support/v6.1 labels Apr 10, 2026
Copy link
Copy Markdown
Contributor

@hannemn hannemn left a comment

Choose a reason for hiding this comment

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

@FlorianReimold Can you give the PR a short review please? Thanks. :-)

@FlorianReimold FlorianReimold self-assigned this Apr 14, 2026
@FlorianReimold FlorianReimold self-requested a review April 14, 2026 07:45
Copy link
Copy Markdown
Member

@FlorianReimold FlorianReimold left a comment

Choose a reason for hiding this comment

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

This is my first review. I will perform another review regarding Unicode correctness. Please stay tuned 😉

testFile.close();
std::remove(testFilePath.c_str());
test_file.close();
std::filesystem::remove(test_file_path);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel like exceptions should be caught or the error_code should be passed, so that a failure while removing the dummy test file does not crash the application.


char unique_path[MAX_PATH];
if (!GetTempFileNameA(tmp_dir.c_str(), "ecal", 0, unique_path) != 0)
if (GetTempFileNameA(tmp_dir.c_str(), "ecal", 0, unique_path) == 0)
Copy link
Copy Markdown
Member

@FlorianReimold FlorianReimold Apr 14, 2026

Choose a reason for hiding this comment

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

Using hardcoded ANSI functions it probably is fine in 99.9% of all cases, as the tmp dir will most likely only consist of 7-bit ASCII characters anyways. However, it it doesn't, this will fail, as the ANSI output is later interpreted as UTF-8 (I think).
Thus, the proper way would be to use the hardcoded Unicode equivalent and convert that to UTF-8.

I found hardcoded ANSI functions in the following functions:

getTempDir

  • GetTempPathA

DirProvider::uniqueTmpDir

  • GetTempFileNameA
  • DeleteFileA
  • CreateDirectoryA

@FlorianReimold
Copy link
Copy Markdown
Member

FlorianReimold commented Apr 14, 2026

Ok, so I did a small test and come to the conclusion that the current implementation does not handle Unicode paths in Windows.

Take the following code for example:

std::string checkForValidConfigFilePath(const std::string& config_file_, const Util::DirProvider& dir_provider_ /* = Util::DirProvider() */, const Util::DirManager& dir_manager_ /* = Util::DirManager() */)
{
std::error_code ec;
const std::string cwd_directory_path = std::filesystem::current_path(ec).string();

When any eCAL App is being started from a path with unicode characters that don't appear in the currently configure codepage (in my test D:\testdir\Beer🍺), the current working directory cannot be represented with 8 bit characters (Which would be ANSI on Windows so depending on the Codepage! But those legacy codepages don't have emojies.) and therefore .string() throws an exception internally and returns an empty string.
The solution for this problem is to call .wstring() on windows to get the UTF-16 path as a string and convert it to UTF-8 for passing it through the code.

Therefore, a deeper analysis has to be done to replace all non-widestring calls with widestring equivalents on windows.

@FlorianReimold FlorianReimold removed their assignment Apr 14, 2026
@FlorianReimold FlorianReimold self-requested a review April 30, 2026 10:05
@FlorianReimold
Copy link
Copy Markdown
Member

I conducted a manual review of the PR changes and didn't find any issues. I think, it should now handle Unicode data properly. I will however continue with a small review of the non-changed codebase as well so see if the surrounding code handles it properly.

Copy link
Copy Markdown
Member

@FlorianReimold FlorianReimold left a comment

Choose a reason for hiding this comment

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

OK, looks good for me. Widestring and UTF 8 was used consistently everywhere I checked. An AI review told me the same. The AI review mentioned that we are currently not supporting long file paths for the temp directory (it uses MAX_PATH) and that there are ways to also support long paths there. But I think the current state is fine.

@Peguen Peguen removed cherry-pick-to-support/v6.0 Cherry pick these changes to support/v6.0 labels May 4, 2026
@Peguen Peguen merged commit 5824b2f into master May 5, 2026
39 checks passed
@Peguen Peguen deleted the feature/path_processing_to_cpp17 branch May 5, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-to-support/v6.1 Cherry pick these changes to support/v6.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants