Skip to content

Deprecated path class#196

Merged
ahcorde merged 8 commits intorollingfrom
ahcorde/rolling/deprecated_path_class
Jul 24, 2024
Merged

Deprecated path class#196
ahcorde merged 8 commits intorollingfrom
ahcorde/rolling/deprecated_path_class

Conversation

@ahcorde
Copy link
Copy Markdown
Contributor

@ahcorde ahcorde commented Jul 8, 2024

We are using C++17, so we can deprecate path class.

This might require some changes downstream

Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde ahcorde requested a review from clalancette July 8, 2024 18:09
@ahcorde ahcorde self-assigned this Jul 8, 2024
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde ahcorde requested a review from clalancette July 9, 2024 13:42
Comment on lines +370 to +396
/**
* \brief Get a path to a location in the temporary directory, if it's available.
*
* This does not create any directories.
* On Windows, this uses "GetTempPathA"
* On non-Windows, this prefers the environment variable TMPDIR, falling back to /tmp
*
* \return A path to a directory for storing temporary files and directories.
*/
RCPPUTILS_PUBLIC std::filesystem::path temporary_directory_path();

/**
* \brief Construct a uniquely named temporary directory, in "parent", with format base_nameXXXXXX
*
* The output, if successful, is guaranteed to be a newly-created directory.
* The underlying implementation keeps generating paths until one that does not exist is found.
* This guarantees that there will be no existing files in the returned directory.
*
* \param[in] base_name User-specified portion of the created directory
* \param[in] parent_path The parent path of the directory that will be created
* \return A path to a newly-created directory with base_name and a 6-character unique suffix
*
* \throws std::system_error If any OS APIs do not succeed.
*/
RCPPUTILS_PUBLIC std::filesystem::path create_temporary_directory(
const std::string & base_name,
const std::filesystem::path & parent_path = temporary_directory_path());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I poked at this a while today with @mjcarroll , and tried to come up with a nicer way to do this. We really couldn't figure out a better way than making a new function name.

However, I pulled down all of the source code released into Rolling. And I found that rcpputils::fs::temp_directory_path and rcpputils::fs::create_temp_directory aren't used anywhere outside of the core. In the core, they are only used in:

  • rcpputils - the implementation and the tests
  • rosbag2_compression - some tests
  • rosbag2_cpp - some tests
  • rosbag2_storage_mcap - a test
  • rosbag2_storage_sqlite3 - a test
  • rosbag2_transport - a test
  • rosbag2_test_common - a test
  • rcl_logging_spdlog - a test

Thus, at the cost of only 3 PRs (this one, one in rcl_logging, and one in rosbag2), we can completely break this API. I think we should do that. In particular, I think we should remove temporary_directory_path and create_temporary_directory, and also remove temp_directory_path. Then we change create_temp_directory to take in a std::filesystem::path, and also return a std::filesystem::path. And then we update the tests here to use std::filesystem::path, as well as the tests in rcl_logging and rosbag2. At the end of those 3 PRs (which will have to be merged at the same time), we'll have the API we want going forward.

Does that make sense to you @ahcorde?

Copy link
Copy Markdown
Contributor

@clalancette clalancette Jul 9, 2024

Choose a reason for hiding this comment

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

Actually, in point of fact, that is a big enough change that I think we should do that on its own, separate from this PR. Once that is in, we can revisit deprecating rcpputils::fs::path separately (i.e. this PR).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Related PR #197

Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

this needs to be rebased on #198.

@@ -0,0 +1,519 @@
// Copyright 2019 Open Source Robotics Foundation, Inc.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Copyright 2019 Open Source Robotics Foundation, Inc.
// Copyright 2024 Open Source Robotics Foundation, Inc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, just realized that @fujitatomoya's comment here is still open.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ahcorde added 2 commits July 22, 2024 10:37
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde
Copy link
Copy Markdown
Contributor Author

ahcorde commented Jul 22, 2024

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Included ros2/rclcpp#2579

ahcorde added 2 commits July 22, 2024 23:16
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Copy link
Copy Markdown
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

One last thing to change here, then this should be good.

@@ -0,0 +1,519 @@
// Copyright 2019 Open Source Robotics Foundation, Inc.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, just realized that @fujitatomoya's comment here is still open.

Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde ahcorde requested a review from clalancette July 23, 2024 10:19
Copy link
Copy Markdown
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

Looks good to me with green CI.

@ahcorde
Copy link
Copy Markdown
Contributor Author

ahcorde commented Jul 23, 2024

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde
Copy link
Copy Markdown
Contributor Author

ahcorde commented Jul 23, 2024

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@ahcorde ahcorde merged commit 6743223 into rolling Jul 24, 2024
@ahcorde ahcorde deleted the ahcorde/rolling/deprecated_path_class branch July 24, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants