Issue 17329 - File.remove() has problems with long filenames (>128 bytes)
Summary: File.remove() has problems with long filenames (>128 bytes)
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Windows
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-16 13:48 UTC by Rainer Koschnick
Modified: 2024-12-01 16:30 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Rainer Koschnick 2017-04-16 13:48:16 UTC
This is a rather weird issue that only pops up in a release build:

std.file.FileException@D:\Dlang\dmd2\windows\bin\..\..\src\phobos\std\file.d(733): 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234.cbr: The system cannot find the file specified.

Filenames up to 128 bytes work fine, anything above it throws this exception.

Building in Visual Studio 2017, output is MS-COFF. The debug build works fine.
Comment 1 basile-z 2017-04-17 12:54:59 UTC
(In reply to Rainer Koschnick from comment #0)
> This is a rather weird issue that only pops up in a release build:
> 
> std.file.FileException@D:\Dlang\dmd2\windows\bin\..\..\src\phobos\std\file.
> d(733):
> 12345678901234567890123456789012345678901234567890123456789012345678901234567
> 89012345678901234567890123456789012345678901234.cbr: The system cannot find
> the file specified.
> 
> Filenames up to 128 bytes work fine, anything above it throws this exception.
> 
> Building in Visual Studio 2017, output is MS-COFF. The debug build works
> fine.

Try

void removeFileEx(string filename)
{
    import std.file : remove;
    return remove("\\?\" ~ filename);
}

Adding the prefix turns the filename into a fully qualified name and should have for effect to remove the MAX_PATH (260 chars) limitation.
Comment 2 Rainer Koschnick 2017-04-18 15:44:13 UTC
Thanks for the hint, but it doesn't change anything.

Error: \\?\0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.cbz: The system cannot find the file specified.

Neither does...

Error: .\0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.cbz: The system cannot find the file specified.

Nor using a complete path...

Error: D:\_Development_\D\cbc\0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.cbz: The system cannot find the file specified.
Comment 3 basile-z 2017-04-20 00:17:37 UTC
I meant fully qualified filename !

\\?\D:\_Development_\D\cbc\...
Comment 4 Rainer Koschnick 2017-04-20 01:00:41 UTC
I tried it with the path as you can see up there!
Comment 5 dlangBugzillaToGithub 2024-12-01 16:30:07 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10247

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB