简体   繁体   中英

_stat fails on networked directory

My program copies files from my Windows laptop to my Windows desktop over the LAN. I use drag&drop from Explorer to provide the source and destination.

The source is: C:\\Paul

The destination is: \\\\SERVER\\Paul

However, _stat(dst,&dst_statbuf) fails with -1 and errno set to ENOENT (file not found).

Note that from Explorer drag & drop the paths provided are correct and exist, and in explorer I can see the destination directory and can open files so permissions seems OK.

Does anyone have any idea why _stat fails?

Found the problem.

In stat64.c (VC2008) there is the curious comment:

/* root dir. ('C:\') or UNC root dir. ('\\server\share\') */

followed by the call to an undocumented API function (line 145):

IsRootUNCName(path)

Indeed, appending a backslash to a server path makes _stat work. But note that calling _stat on a regular directory on the server path also works. So it only fails on the root of the share.

I consider this a bug (or at least an incongruency between Windows Explorer and _stat )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM