Fix issue 17167 - handle long filepaths on Windows#7299
Fix issue 17167 - handle long filepaths on Windows#7299dlang-bot merged 4 commits intodlang:masterfrom
Conversation
|
Thanks for your pull request, @atilaneves! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla references
|
src/ddmd/root/filename.d
Outdated
|
|
||
| Please consult | ||
| https://msdn.microsoft.com/en-us/library/windows/desktop/aa363855(v=vs.85).aspx | ||
| */ |
There was a problem hiding this comment.
Please use Ddoc style comments. In particular, this needs a Params: section, a Returns: section, and the Please consult should be References:. Ditto for the rest of the added functions.
src/ddmd/root/filename.d
Outdated
| const lastError = GetLastError(); | ||
|
|
||
| // Preserve compatibility with mkdir since the calling code expects | ||
| // errno to be set. |
There was a problem hiding this comment.
Don't need compatibility since there is only one caller of this private function. Please don't use errno on Windows unless forced to.
src/ddmd/root/filename.d
Outdated
| const length = MultiByteToWideChar(0 /*codepage*/, 0 /*flags*/, str, strLength, null, 0); | ||
| if (!length) return null; | ||
|
|
||
| auto ret = length > buf.length ? new wchar[length] : buf; |
There was a problem hiding this comment.
The new is a memory leak in dmd. Take a look at https://github.com/dlang/phobos/blob/master/std/internal/cstring.d#L122 where malloc is used for the temporary buffer, cleaned up with free().
There was a problem hiding this comment.
I thought that leaking was the memory strategy for dmd in order for it to be fast and that at some point the GC would be turned on. The code you linked is from Phobos, so do you mean I should create a similar struct for dmd or just to use free to clean up?
There was a problem hiding this comment.
I changed how things are done now. The leak is no longer there, at the sake of some more complexity.
|
This problem was fixed in Phobos in std.file long ago :-) |
83a5648 to
14834da
Compare
This issue is made more grave by the fact that dub uses relative file paths for any package dependencies. This means that if your project is in
C:\foo\bar\baz\quux, it'll try writing toC:\foo\bar\baz\quux\..\..\..\..\Users\%USERNAME%\AppData\Roaming\dub\packages\%PACKAGE_VERSION%\%PACKAGE%\.dub\%HASH%. This gets big quite quickly and goes over Windows's 260 character file path limit, meaning that dub build fails with a message saying that it can't write to a certain directory.This PR fixes the issue by using the newer unicode-aware Win32 APIs, which don't have the limitation.