On Wednesday, 19 September 2018 at 05:49:41 UTC, Nick Sabalausky (Abscissa) wrote:
[...]

Someone mentioned in this thread that .NET runtime does do the long-path workaround automatically. One thing we could do is copy EXACTLY what C# is doing.

The rationale being that:
- .NET is made by Microsoft
- The Windows API's filesystem implementation is made by Microsoft
- Given that these two are made by the same party, it's reasonable to assume that the .NET authors authoritatively "knew what they were doing" when implementing the workaround. - The algorithm used by .NET is very likely to be supported by the API (even future implementations), as well as third-party implementations of the API.

However, there are still drawbacks to this:

- There is still the matter of overhead (one OS API call (GetCurrentDirectory) and at least one GC allocation (for the current directory buffer)). - Using paths longer than MAX_PATH is an exceptional situation. Putting the workaround in the main code path penalizes 99.9% of use cases. - The registry switch in newer Windows versions removes the need for this workaround, so systems with it enabled are penalized as well. - There is still the matter regarding special filenames, as well as whether the expected behavior is really to succeed and create paths inaccessible to most software, instead of failing.

Reply via email to