-
Notifications
You must be signed in to change notification settings - Fork 888
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
I agree, I would also just move over the basename/filename function, there are already directory/file related functions present in yosys_common |
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); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
See #4592 (comment)