visual c++ - Windows with mapped drive -- _stat() fails to detect existence of the file -
summary: _stat()
function says there not existing file when drive letter mapped unc path.
details: on windows system, there unc path
\\computer\sharename\disk_m\the_subdir\file.txt
and mapped way:
net use m: \\computer\sharename\disk_m
then file.txt
can accessed m:\the_subdir\file.txt
, , can see content in editor.
the problem need test file existence in program. use following function:
bool isfile(const std::string & path) { struct _stat stat; if (_stat(path.c_str(), &stat)) return false; // call returns -1 errno enoent return (stat.st_mode & _s_ifreg) != 0; }
when debugging, have found _stat
calls findfirstfile
function:
/* call find match file */ findhandle = findfirstfile((_tschar *)name, &findbuf); if ( findhandle == invalid_handle_value ) { _tschar * pbuf = null;
... , fails find file here.
what problem? doing wrong? how can enhance detection of existence of file? (the code runs in environment drive mapping made local administrator, , cannot change configuration.)
Comments
Post a Comment