_hunter

Greetings...

Is there a way to use long file/dir names with _stat function I've tried to prepend path with \\ \ and use _wstat (it works for _wopen) -- it not works: in this case _wstat returns -1 and errno == ENOENT even for short pathes. If not prepend path -- function works nice (but only with short names).

Best regards...


Re: Visual C++ General _stat() and long names

Sdi

"Use the Source, Luke"....

_stat() has internal wildcard-prevention code that conflicts with the \\ \reallylongname.... facility:

/* Don't allow wildcards to be interpreted by system */

#ifdef _UNICODE

if (wcspbrk(name, L" *")) {

#else /* _UNICODE */

if (_mbspbrk(name, " *")) {

#endif /* _UNICODE */

errno = ENOENT;

_doserrno = E_nofile;

return(-1);

}

You have the RTL sources, so you can answer questions like these quicker on your own.





Re: Visual C++ General _stat() and long names

_hunter

Ok. I knew the source of the problem now. But what I should do with it -- Rebuld RTL





Re: Visual C++ General _stat() and long names

Sdi

What information do you expect to get from _stat() that you can't get by calling FindFirstFile() yourself That's basically all _stat() does; cut out the middle man.





Re: Visual C++ General _stat() and long names

_hunter

There is a lot of legacy code, which is used _stat structure...

Also, by some reason, GetFileAttributesW not works with long names to...

Same problem with FindFirstFileW -- it searches something like "\\ \c:\Workspace\test\q" but not searches \\ \c:\Workspace\test\qqqqq...[total 320 q]...





Re: Visual C++ General _stat() and long names

Sdi

As documented (OK, you have to look for it), the \\ \realpathhere convention only lets you extend the total path length; the individual components (i.e. any given directory name or the file name) are still limited to 255 characters each. Open the documentation page for FindFirstFile, follow the "Naming a File" link under the 'lpFileName' parameter, and start reading under "Maximum Path Length".