phobo's std.file is completely broke!

Nick Sabalausky (Abscissa) SeeWebsiteToContactMe at semitwist.com
Wed Sep 19 02:20:45 UTC 2018


On 09/18/2018 09:46 PM, Jonathan M Davis wrote:
> On Tuesday, September 18, 2018 7:28:43 PM MDT Nick Sabalausky (Abscissa) via
> Digitalmars-d wrote:
>>
>> It's worth noting that the discussion made it very clear that Walter's
>> viewpoint on the matter was based on his own misunderstanding (ie,
>> mistakenly failed to notice that `\\?\` != `\\.\`) He never actually
>> made any comment after that was pointed out.
> 
> If a clean, simple solution can be found that allows long paths on Windows
> to work seemlessly without subtle side effects, then I don't see why it
> can't be implemented, but it needs to be something that's not going to cause
> problems. Otherwise, it needs to be left up to the caller to do whatever
> happens to be correct for their particular circumstances. We want Phobos to
> work seemlessly across platforms where reasonably possible, but
> unfortunately, it's not always reasonable. Either way, Microsoft has clearly
> made a mess of this. So, I don't know how reasonable it is to work around
> it. Regardless, we either need to figure out a sane way to work around the
> problem (without causing new problems in the process) or document it so that
> the situation is clear.
> 

Exactly. And this is precisely why I'm irritated by just how much of 
this entire thread has been meaningless high-level philosophical 
hand-wringing, with barely any attention paid to the technical details 
of the problem itself.

Though I admit, I've allowed myself to get dragged into it, too. So 
allow me to rectify that:

1. For reference, here is the relevant MS documentation:
https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#file-and-directory-names

2. For reference, here is the existing bug report discussion:
https://issues.dlang.org/show_bug.cgi?id=8967

3. Building on what Vladimir and Jay have said in the bug report, I 
propose we do this:

- We add a public function to Phobos which takes a a UTF-8 path and does 
the following:
     - No-op outside of Windows
     - No-op if the path is less than MAX_PATH-12 bytes. (Worrying about 
the case where the real limit is MAX_PATH-1 would be inconsequential and 
thus needless.)
     - No-op if the path begins with "\\" (and is therefore either a 
network share path, a "\\.\" device path, is already a "\\?\" path, or 
is just some undetectable malformed path that happens to look like one 
of the above)
     - Otherwise, returns:
         toUTF16z(buildNormalizedPath("\\?", path.toAbsolute))
     - By "no-op" above, I really mean: toUTF16z(path)
- In all cases where Phobos passes a path to WinAPI, the path is first 
passed through this function (except for any specific cases where it can 
be shown that the path should NOT be passed through this function).

4. What technical problems does this proposal have?

5. For each technical problem with the proposal: How can the proposal be 
adjusted to compensate? Or, why can the technical problem NOT be 
reasonably solved? Or in general: How should this proposal be modified, 
and why?



More information about the Digitalmars-d mailing list