-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fast native file system path abstraction #1
Comments
Do we need to parse non-local file system paths? Example: parse I guess we have to come up with some examples. |
In my opinion, parsing non-local file system paths is a thing for #2. But you've raised a good question, actually. I guess we'll need different "codecs" (or something else) for different file systems anyway, and if we're having it – then why not make them user-visible? |
Ok, we can forbid to compare path with different codecs for now. Therefore I suggest to develop support for single platform (Windows?) at start. |
I would say that such a path is always an absolute one. Do you think there are cases when it's not?
Yep, I think we could start from that. |
Simple mistake like:
So, will we support wild-card paths? Will we support What will we do with restricted characters? Like from There are DOS path specifiers ( How to store parsed data in memory? I think the best way is collection of How to iterate through path's segments? There is no full tree or graph, so simple 'flat' collection (Array or LinkedList) is enough. |
Please note that the default behavior of path-combining functions, such as I would like to preserve this behavior by default. But (and that's a big but!) the main point of the library is to make paths more strongly typed, to avoid such issues. A prototype API I imagine looks like that: // this is always absolute; will assert in the constructor
struct AbsolutePath
{
// autodetect path kind, behave as Path.Combine if passed an absolute path
public LocalPath operator / (string relativeOrAbsolute);
// note no necessity of any kind of "autodetection"
public LocalPath operator / (RelativePath relative);
}
// in this struct, we may allow to pass paths such as `/random` and convert them into `random`, perhaps not by default
// but via a ctor overload which will allow to pass various flags such as "TreatUnixRootedPathAsRelative"
struct RelativePath {} This is all debatable, of course.
As of now, this is not one of the main points of the library, but I have nothing against implementing that in the near future.
I believe that we should normalize paths by default, but we may discuss.
I think yes, just throw an exception from, the path constructor.
We should do something about them (and network paths, too), but it may be another "codec".
That's a good question. Not sure about In ReSharper, there's an interning system for their
I guess, in this case, we can have an API like |
To preserve we can use such functions internally, can't we?
Wow, I like it! Use / operator is great idea!
Yep, I tried to imagine use-case for store info about '..' but actually couldn't. So ok, let's normalize.
How do you suggest to choose specific codec? Im/explicitly?
Yes, agree with you.
How it works? Could you show docs or something please?
Yep, or implement IEnumerable. How to parse raw parse? Should we use regex? I think simple 'Split' is not enough (cause of |
We can use them of course (though this won't probably be in line with the "zero-alloc" approach), or we can reimplement them on our own. We were only discussing the behavior and not the implementation here, in my opinion.
This is something open for discussion. I have in mind the implementation of so-called "interaction contexts" from ReSharper (where each path gets its own "interaction context" and will parse the paths accordingly), but this isn't set in stone.
This isn't documented (and is thus subject to change), but basically it works like this: there's a static interning cache, where the key is the path passed to a method So, this is only optimized for cases when you pass the same path to Note that the keys in the cache are before canonicalization. I'm not saying we should do something like this, but this is a possibility.
In any case, this is a very simple routine with linear complexity (until we start considering various weird path parameters like partial case-sensitivity). So, any simple implementation would work, provided it does no unnecessary allocations. I think, by default our path should store a canonicalized path string inside of itself, and send parts of it when requested by APIs that enumerate its components. Whether we should add anything to work with |
Great idea, but I don't understand how it should be implemented. I think it is not the task with first priority. We should create issue and discuss later.
Yep, string-based overloads with |
I am closing this issue as mostly implemented, and extracting the remaining parts to a set of separate, more focused issues. |
(#42) IPath: introduce a generic interface
So, we need an abstraction over a file system path which:
Open questions:
The text was updated successfully, but these errors were encountered: