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
Provide a way of getting a file's real path #35370
Comments
Note that something like |
You dont want to resolve symbolic links? I think that the norm for this type of thing. Personally I dont have a preference either way, but do you have something youre looking to as an example? Just as one data point, PHP does resolve symlinks: https://php.net/function.realpath what about: |
From
That doesn't handle the case where the input path uses different capitalization than the path on disk. |
Honestly I am not sure what the expected result is here. As an example using
Why does Dart |
The expected result, as I explained in the original comment, is the output of
In my case, because I need to canonicalize files based on their paths, and canonicalizing |
@nex3 I get that for your case its needed, but have you come across an implementation in any other programming language that does what you expect? If not, maybe this would make more sense in a personal library than in the official SDK. |
Yes, C and C++, as well as any language that provides access to the underlying operating system's APIs (such as Ruby).
How would I go about doing this, exactly? |
@nex3 are you sure about that?
|
But the old Win32API standard library provided direct access to the APIs in question. |
The Windows API is not a programming language, its a method to access low level system calls, similar to the Linux API: https://en.wikipedia.org/wiki/Linux_kernel_interfaces It does make sense to have support for this with certain programming languages. For example Go has the syscall library: https://golang.org/pkg/syscall I dont know if it makes sense for Dart to have something like this, as I consider it more high level. But even if Dart has syscall support at the user level, thats not really an implementation of a particular task so to speak. For example, if you want to open a file with Go, youre going to use the All this is to say that I dont think pointing to programming languages that have a syscall library is a good justification of why the issue in the original post should be implemented. With that justification, you could say really anything in the Windows API should be implemented in the Dart standard library. |
I do indeed think that Dart should provide a way to do pretty much anything supported by native OS APIs, especially when it's supported across all platforms that Dart supports. Whether that's a syscall library, an encapsulation of this particular syscall, or a portable means of writing our own syscalls, I don't really care—all I asked for was a way to make this possible. |
Fair enough. However unless we can point to other languages that have a I havent done thorough testing, but the languages I have tested dont act the way you propose, so I agree with you that it makes sense for it to be possible, just maybe not the default. |
I'm not sure why you think I want this to be part of |
What you do think about Dart creating a syscall package? That way your use case would be available as well as others |
That would be great. I think it would need to be a core library, though, not a package. |
That sounds good to me |
Right now, given a user-provided file path, there's no (efficient) way of getting that file's real path on disk. On Linux et al these are always the same thing (modulo
.
and..
path components whichp.normalize()
can handle), but Windows and some OS X systems have case-insensitive filesystems where a file namedFILE.TXT
can be referred to by the pathfile.txt
. Worse yet, some servers appear to only serve the files in question if the case matches exactly, even when the underlying filesystem is case sensitive (see sass/dart-sass#540).It's possible to work around this today using
Directory.list()
on the parent directory, but that's much more expensive than a single call. I believe you can useFindFirstFileA
for this on Windows andfcntl
withF_GETPATH
on Unixes.The text was updated successfully, but these errors were encountered: