Comments (6)
from path_abs.
I'm working on this right now, actually! I just figured I should have an issue number to mention in the commit that makes the change.
Sure, I'd love to help. :)
from path_abs.
Cool, you've been added as a collaborator.
I actually mistakenly thought this was the PR in the email. Carry on 😄
from path_abs.
A couple of days ago I discovered the problem that arc::handle_prefix()
was intended to solve had not gone away, and I figured out how to reproduce it reliably. The following table is one I posted to rust-lang/rust#49342 but with a few more interesting test-cases I thought of in the mean time. As before, the intersection of each column and row represents the result of std::env::set_current_dir(column); Path::new(row).canonicalize()
where "-" means "returned an error":
\\?\C:\ |
C:\ |
\\vboxsvr\Shared\ |
|
---|---|---|---|
\\vboxsvr\Shared\ |
\\?\UNC\vboxsvr\Shared\ |
\\?\UNC\vboxsvr\Shared\ |
\\?\UNC\vboxsvr\Shared\ |
\\?\C:\Users |
\\?\C:\Users |
\\?\C:\Users |
\\?\C:\Users |
C:\Users |
\\?\C:\Users |
\\?\C:\Users |
\\?\C:\Users |
C:Users |
- | \\?\C:\Users |
- |
\Users |
- | \\?\C:\Users |
\\?\UNC\vboxsvr\Shared\Users |
Users |
\\?\C:\Users |
\\?\C:\Users |
\\?\UNC\vboxsvr\Shared\Users |
C: |
\\?\C:\Users\IEUser |
\\?\C:\ |
\\?\C:\Users\IEUser |
\ |
- | \\?\C:\ |
\\?\UNC\vboxsvr\Shared\ |
When the current directory is a regular (C:\
) or UNC (\\vboxsvr\Shared
) path, you can canonicalize just about anything, so we don't have to do anything special to make canonicalization work for those cases.
The path C:Users
fails to canonicalize for both the extended-length (\\?\C:\
) and UNC paths, which makes sense. As the C:
row reveals, in those cases the current directory on C: is "\Users\IEUser" which does not contain a Users directory, so .canonicalize()
is correct to return an error in those situations. We don't have to do anything special to make canonicalization work for those cases (beyond the work we already have to do to support canonicalizing non-existent paths).
The paths \Users
and \
fail to canonicalize when the current directory uses extended-length syntax. Luckily, we can easily implement this ourselves:
- take the prefix from the current working directory (say,
C:
) - add a root component (
C:\
) - canonicalize that (
\\?\C:\
) - add the remainder of the input path to that head (
\\?\C:\Users
)
So, in every situation we can produce a canonical path head for an arbitrary input path, even on Windows, and even if the current working directory uses extended-length path syntax.
I'm gonna try to re-implement PathArc::absolute()
like that, and we'll see how far I get.
from path_abs.
from path_abs.
Not strictly related to solving this issue, but this Raymond Chen blog post explains a whole bunch of the weirdness I've encountered with relative path resolution on windows. The short version is: unlike Unix, where the shell is a thin wrapper over the kernel's idea of a "process", Windows' cmd.exe
lies all the time.
from path_abs.
Related Issues (20)
- Help in handling weird join behavior HOT 16
- resolving resulted in empty path when resolving absolute . HOT 4
- Notes from a new user HOT 8
- Move PathArc to botom of docs and make it more clear that it is an implementation detail HOT 1
- `PathAbs` has incorrect docs HOT 2
- What should happen when canonicalizing `..` at the root? HOT 3
- PartialOrd and PartialEq traits HOT 6
- Internationalization (i18n) support
- Types probably shouldn't implement the `Deref` trait. HOT 9
- PathAbs constructor cleanup HOT 2
- windows path handling HOT 5
- Add `join` back HOT 1
- File* Constructor cleanup
- put join fn in PathOps
- Inherent methods for PathOps and PathInfo HOT 6
- add wasm32-wasi target HOT 2
- WASI symlink implementation is incorrect HOT 7
- Idea: Give FileWrite a `write_fmt` inherent method HOT 2
- Making Stdio from {FileRead, FileWrite} HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from path_abs.