-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Path::file_stem()
does not work with directories that contain dots
#133399
Comments
This is likely (?) intentional behavior. Some devs operate on abstract paths that don't necessarily exist on a mounted filesystem. It is also worth noting that checking if a path is a directory would introduce a new syscall to |
@ryanavella I disagree. A directory does not have an extension, so we cannot return a file stem (or extension for that matter). I see that an additional syscall is required for my suggestion, but I don't see the use of the For abstract paths, which do not exist on the filesystem, the |
The problem is if a process calls |
Some systems do use extensions with directories. For example, on OSX, apps are distributed as app bundles, which are just directories with the extension ".app". |
Fair point. Yes.
I see.. Python's pathlib also handles it the same way. However, I still think that cases where there are dots occurring in the name of a directory, the behavior of the |
I'm dealing with directories that contain dots in the name:
I expected it to just return the pure filename, since it does not have an extension/suffix.
"2024.11.23_directory"
Instead, it just returns whatever is before the last dot:
"2024.11"
Meta
rustc --version --verbose
:This happens in the source code in
path.rs
where:This clearly shows that it just splits the filename at the last dot, regardless if it is a directory or a file.
The text was updated successfully, but these errors were encountered: