Re: [PATCH] Add a new lstat implementation based on Win32 API, and make stat use that implementation too.
- From
Marius Storm-Olsen <marius@trolltech.com>
- Date
- Sep 3, 2007, 06:12 UTC
- Message-ID
- <46DBA5E8.105@trolltech.com>
- In-Reply-To
- <20070902214128.GC2756@steel.home>
Alex Riesen said the following on 02.09.2007 23:41:
> Marius Storm-Olsen, Sun, Sep 02, 2007 21:31:40 +0200: >> + buf->st_ino = 0; > > You sure about that? Ever wondered why it is not so on everywhere else?
Pretty sure. If you look at Windows' native version of stat, it will return you st_ino = 0. Or maybe you where referring to something else, and I just missed your point?
AFAIK, the ino in the index is only to be _really_ sure that nothing has changed with the file, and we can just skip it on Windows. If in doubt, try running this on your Windows box:
#include <windows.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h>
int main(int, char **)
{
wchar_t DirSpec[] = L".\\*";
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile(DirSpec, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE) {
printf ("Crap happened: %u\n", GetLastError());
return -1;
} struct _stat buf;
while (FindNextFile(hFind, &FindFileData) != 0)
{
if (!_wstat(FindFileData.cFileName, &buf))
printf("file: %S, ino: %u\n", FindFileData.cFileName, buf.st_ino);
} FindClose(hFind);
return 0;
}-- .marius