www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23392] New: "File does not exist" while the real error is

https://issues.dlang.org/show_bug.cgi?id=23392

          Issue ID: 23392
           Summary: "File does not exist" while the real error is
                    "ENAMETOOLONG (File name too long)"
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: kdevel vogtner.de

```fdne-vs-fntl.d
module file_does_not_exist__vs__file_name_too_long;
import std.stdio;
import std.file;

version (Posix):

string make_long_filename ()
{
   immutable char [256] longname = 'X'; // assuming NAME_MAX is 255
   return (cast (string) longname).dup ();
}

void main ()
{
   auto fsoname = make_long_filename ();
   auto de = DirEntry (fsoname);
}
```

$ dmd -g fdne-vs-fntl.d
$ strace -festat,lstat ./fdne-vs-fntl 
lstat("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
0x7fffffffd6d8) = -1 ENAMETOOLONG (File name too long)
std.file.FileException std/file.d(3887):
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:
File does not exist
----------------
??:? ref  safe std.file.DirEntry std.file.DirEntry.__ctor(immutable(char)[])
[0x4b383d]
./fdne-vs-fntl.d:16 _Dmain [0x4b1130]

The lstat call is performed in existsImpl while DirEntry is constructed. Alas,
errno is not checked.

--
Oct 06 2022