Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Replace some uses of Poco::Path with std::filesystem::path #38761

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

jclarkeSTFC
Copy link
Contributor

@jclarkeSTFC jclarkeSTFC commented Jan 30, 2025

I've replaced some usages of Poco::Path with std::filesystem::path, and in some places where strings were being used to represent paths I switched to std::filesystem::path. I made changes to ConfigService so would be good to give this a thorough check. See #37868 for further details on this migration.

Note: Poco::Path::expand does not have an equivalent in the standard library, it expands all environment variables in the path.

One gotcha I found, if you thought that Poco::Path::makeDirectory would make a directory, then you'd be wrong, it removes the filename from the Poco::Path object.

Refs #37868.

To test:

This does not require release notes because this is an internal refactor, API should stay the same.


Reviewer

Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.

Code Review

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

Does everything look good? Mark the review as Approve. A member of @mantidproject/gatekeepers will take care of it.

Gatekeeper

If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.

@jclarkeSTFC jclarkeSTFC added Maintenance Unassigned issues to be addressed in the next maintenance period. ISIS Team: Core Issue and pull requests managed by the Core subteam at ISIS labels Jan 30, 2025
@jclarkeSTFC jclarkeSTFC added this to the Release 6.13 milestone Jan 30, 2025
@jclarkeSTFC jclarkeSTFC force-pushed the 37868_migrate_to_std_filesystem branch 7 times, most recently from 0e34c60 to f1acfba Compare February 5, 2025 09:25
@jclarkeSTFC jclarkeSTFC added the Extra Attention Testers and Gate keepers should pay extra attention as this affects core aspects. label Feb 5, 2025
@jclarkeSTFC jclarkeSTFC force-pushed the 37868_migrate_to_std_filesystem branch 5 times, most recently from 394349c to b55c5d9 Compare February 12, 2025 14:48
@github-actions github-actions bot added the Has Conflicts Used by the bot to label pull requests that have conflicts label Feb 14, 2025
Copy link

👋 Hi, @jclarkeSTFC,

Conflicts have been detected against the base branch. Please rebase your branch against the base branch.

Poco::Path::expand does not have an equivalent in the standard
library.
To maintain the same Python API, return std::strings when getting
directories from ConfigService.
Turns out it just removes any filename from the path object, so
the equivalent is std::filesystem::path::remove_filename.
Representing a path as a string causes pain because you have to
worry about whether or not there is a slash, which direction is
the slash on which OS, etc.
Poco::Path::resolve did not like the std::filesystem::path not having
a slash at the end (!), so I removed Poco to make this method use
std instead.
Poco::Path::isDirectory only checks if the Poco::Path object has something
labelled as a filename, not necessarily if it exists. Hence to get the
same functionality we need to check if the path exists or not, and also
if it is a directory or not. If it's an existing file then it's no
good.
Msbuild apparently is not happy with creating Poco::File objects
from std::filesystem::path so I gave it some help.
We shouldn't use a string to represent a file path, because then we
have to worry about slashes and which way they're going, etc.
Msbuild requires that .string() on std::filesystem::path be called in a
variety of places, whereas Clang and GCC don't have a problem going
from a std::filesystem::path to a Poco::Path via a string.
@jclarkeSTFC jclarkeSTFC force-pushed the 37868_migrate_to_std_filesystem branch from 3cbfb29 to 559b0a0 Compare February 14, 2025 16:08
@jclarkeSTFC jclarkeSTFC removed the Has Conflicts Used by the bot to label pull requests that have conflicts label Feb 14, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Extra Attention Testers and Gate keepers should pay extra attention as this affects core aspects. ISIS Team: Core Issue and pull requests managed by the Core subteam at ISIS Maintenance Unassigned issues to be addressed in the next maintenance period.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant