www.digitalmars.com         C & C++   DMDScript  

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


          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

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 
0x7fffffffd6d8) = -1 ENAMETOOLONG (File name too long)
std.file.FileException std/file.d(3887):
File does not exist
??:? ref  safe std.file.DirEntry std.file.DirEntry.__ctor(immutable(char)[])
./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