Skip to content
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

File.remove() has problems with long filenames (>128 bytes) #10247

Open
dlangBugzillaToGithub opened this issue Apr 16, 2017 · 4 comments
Open
Labels
Arch:x86 Issues specific to x86 OS:Windows Issues Specific to Windows Severity:Enhancement

Comments

@dlangBugzillaToGithub
Copy link

arkay reported this on 2017-04-16T13:48:16Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=17329

Description

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.
@dlangBugzillaToGithub
Copy link
Author

b2.temp commented on 2017-04-17T12:54:59Z

(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.

@dlangBugzillaToGithub
Copy link
Author

arkay commented on 2017-04-18T15:44:13Z

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.

@dlangBugzillaToGithub
Copy link
Author

b2.temp commented on 2017-04-20T00:17:37Z

I meant fully qualified filename !

\\?\D:\_Development_\D\cbc\...

@dlangBugzillaToGithub
Copy link
Author

arkay commented on 2017-04-20T01:00:41Z

I tried it with the path as you can see up there!

@LightBender LightBender removed the P4 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch:x86 Issues specific to x86 OS:Windows Issues Specific to Windows Severity:Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants