Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add utility function to get the size of a file #28

Closed
wants to merge 6 commits into from

Conversation

piraka9011
Copy link

Changes

  • Implemented a std::fs::file_size shim.
  • Added a temporary directory fixture for GMock
  • Add a unit test for file_size().

Signed-off-by: Anas Abou Allaban allabana@amazon.com

Anas Abou Allaban added 2 commits December 18, 2019 10:05
Signed-off-by: Anas Abou Allaban <allabana@amazon.com>
Signed-off-by: Anas Abou Allaban <allabana@amazon.com>
Copy link
Contributor

@zmichaels11 zmichaels11 left a comment

Choose a reason for hiding this comment

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

A few style nits

@piraka9011 piraka9011 marked this pull request as ready for review December 18, 2019 21:08
@piraka9011 piraka9011 requested a review from a team as a code owner December 18, 2019 21:08
Signed-off-by: Anas Abou Allaban <allabana@amazon.com>
Signed-off-by: Anas Abou Allaban <allabana@amazon.com>
Copy link

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

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

Let's clean-up this PR and remove all the C code whenever possible:
char * -> std::string, etc.

@piraka9011
Copy link
Author

@thomas-moulard FYI, temporary_directory_fixture.hpp was taken from rosbag2_storage so was unsure how much of it we'd need to revise accordingly.
I'll refactor some of the utility functions and break it down as needed.

@zmichaels11 Take a look at some of the constexpr/char[] suggestions.

@thomas-moulard
Copy link

We should probably clean both IMHO.

Signed-off-by: Anas Abou Allaban <aabouallaban@pm.me>
Signed-off-by: Anas Abou Allaban <aabouallaban@pm.me>
Copy link

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

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

Unblocking this I'm OOO from next week.

@piraka9011
Copy link
Author

piraka9011 commented Dec 23, 2019

Unblocking this I'm OOO from next week.

If you have any comments/suggestions tho lmk!

Most likely I will introduce the Windows and Linux fixes separately.

@piraka9011
Copy link
Author

After discussion with @emersonknapp , this may not be the best approach, rather, create a wrapper around the C++17 FileSystem API with CMake linkers to C bindings.

Copy link

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

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

@piraka9011 The TCHAR code seems to instantiate a variable w/o using it - could you PTAL?

Comment on lines +27 to +28
src/find_library.cpp
src/filesystem_helper.cpp)

Choose a reason for hiding this comment

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

alphasort

// Increase length by two to add the double null termination
const auto char_length = strlen(text.c_str());
const auto new_text = std::make_unique<TCHAR[]>(char_length + 2);
// memcpy(temp_dir, text.c_str(), length);

Choose a reason for hiding this comment

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

remove

void remove_directory_recursively(const std::string & directory_path)
{
#ifdef _WIN32
const auto null_terminated_directory = create_double_null_terminated_tchar(directory_path);

Choose a reason for hiding this comment

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

This is never used?

@piraka9011
Copy link
Author

Resolved by ros2/rcutils#197

@piraka9011 piraka9011 closed this Jan 13, 2020
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