Hello @Radim Langer ,
The _tstat64 function is actually a package of GetFileAttributesEx and _getdrive. You can add <windows.h> and <direct.h>to your project to call these two functions separately. The minimum supported system is windows xp.
int CDECL _tstat64(const _TCHAR *path, struct __stat64 *buf)
{
DWORD dw;
WIN32_FILE_ATTRIBUTE_DATA hfi;
unsigned short mode = ALL_S_IREAD;
int plen;
TRACE(":file (%s) buf(%p)\n",path,buf);
plen = _tcslen(path);
while (plen && path[plen-1]==' ')
plen--;
if (plen && (plen<2 || path[plen-2]!=':') &&
(path[plen-1]==':' || path[plen-1]=='\\' || path[plen-1]=='/'))
{
*_errno() = ENOENT;
return -1;
}
if (!GetFileAttributesEx(path, GetFileExInfoStandard, &hfi))
{
TRACE("failed (%d)\n",GetLastError());
*_errno() = ENOENT;
return -1;
}
memset(buf,0,sizeof(struct __stat64));
/* FIXME: rdev isn't drive num, despite what the docs say-what is it?
Bon 011120: This FIXME seems incorrect
Also a letter as first char isn't enough to be classified
as a drive letter
*/
if (isalpha(*path)&& (*(path+1)==':'))
buf->st_dev = buf->st_rdev = toupper(*path) - 'A'; /* drive num */
else
buf->st_dev = buf->st_rdev = _getdrive() - 1;
...
Refer: _tstat64
You can also use the GetFileInformationByHandle function to obtain file information. The minimum supported system for this function is Windows XP.
typedef struct _BY_HANDLE_FILE_INFORMATION {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD dwVolumeSerialNumber;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD nNumberOfLinks;
DWORD nFileIndexHigh;
DWORD nFileIndexLow;
} BY_HANDLE_FILE_INFORMATION, *PBY_HANDLE_FILE_INFORMATION, *LPBY_HANDLE_FILE_INFORMATION;
Thank you!
----------
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.