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

Refactor getting dirs and filenames from paths to files #4596

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

widlarizer
Copy link
Collaborator

Copy link
Member

@whitequark whitequark left a comment

Choose a reason for hiding this comment

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

I liked the idea of factoring out the code rather than the constants a lot more.

@phsauter
Copy link
Contributor

I agree, I would also just move over the basename/filename function, there are already directory/file related functions present in yosys_common

@widlarizer widlarizer changed the title reduce OS ifdefs with OS_PATH_SEP Refactor getting dirs and filenames from paths to files Sep 11, 2024
@phsauter
Copy link
Contributor

looks good to me


// Includes OS_PATH_SEP at the end
std::string parent_from_file_path(std::string path) {
return path.substr(0, path.find_last_of(OS_PATH_SEP)+1);
Copy link
Member

Choose a reason for hiding this comment

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

What happens if path.find_last_of(OS_PATH_SEP) returns std::string::npos?

Copy link
Member

Choose a reason for hiding this comment

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

To me it looks like it'll return "", which does not include OS_PATH_SEP at the end. This either needs a documentation change or an assertion.

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