>>>>> "Craig" == Craig Lanning <CraigL(a)DyCon.com> writes:
Hi All,
this article discusses FILETIME handling on NT and 9[58] and puts up
the question how to best cope with it in XEmacs (native and mingw32).
Please bear with me while I give Craig two anserws. Other may
fast-forward to
My analysis:
Craig> Are these files on an NTFS disk or FAT disk?
These files are all on NTFS.
Craig> My files are on a FAT32 disk.
Craig> Does NTFS store the timestamp as a GMT integer like unix?
Yes, that's it.
Here's an extract from MSDN, which is still true for NT4:
FileTimeToLocalFileTime() Adjusts for Daylight Saving Time
Last reviewed: September 25, 1995
Article ID: Q128126
The information in this article applies to:
Microsoft Win32 Application Programming Interface (API) included with:
- Microsoft Windows NT version 3.5
SUMMARY
Under NTFS, the API GetFileTime() returns the create time, last access
time, and last write time for the specified file. The times returned
in the FILETIME structures are in Universal Coordinated Time
(UTC). This is also the time that NTFS uses. You can use
FileTimeToLocalFileTime() to convert a file time to a local
time. However, if you automatically adjust for Daylight Saving Time,
FileTimeToLocalFileTime() will adjust for Daylight Saving Time based
on whether the current date should be adjusted for Daylight Saving
Time, not based on whether the date represented by the FILETIME
structure should be adjusted.
The behavior in this situation is different under FAT, but may be
changed to match the behavior under NTFS in a future version of
Windows NT.
<lines deleted by Adrian>
The FAT file system stores local time, not UTC. GetFileTime() gets
cached UTC times from FAT. In this sample, the time stored is 1pm and
the cached time is 9pm. When it becomes Daylight Saving Time, sample
codes 1 and 2 will demonstrate the same behavior that they do under
NTFS, because 9pm is still used. However, when you restart the
machine, the new cached time will be 8pm (UTC = LocalTime + 7). The
call to FileTimeToLocalFileTime() cancels the adjustment made by
GetFileTime() (LocalTime = UTC - 7). Therefore, sample code 1 will
report the correct time under FAT, but sample code 2 will not. On the
other hand, FindFirstFile() on FAT always reads the time from the file
(stored as local time) and converts it into UTC, adjusting for DST
based on the current date. So if FindFirstFile() is called, the date
is changed to a different DST season, and then FindFirstFile() is
called again, the UTC returned by the two calls will be different.
Craig> (FAT and FAT32 do not.) If so, that would explain why you
Craig> see the time change in Explorer.
Exactly.
My analysis:
I guess MS ``designed´´ FileTimeToLocalFileTime to interpret a
FILETIME according to a computer's current DST and TZ setting because
they have no way to know what a FAT FILETIME really means (by design,
yeah right) since it is stored in local time.
My vote is for doing it RIGHT for NTFS and POSIX partitions,
interpreting these as UTC, and interpreting FAT partition file times
to be relative to the current TZ and DST.
That's all we can do, right?
Craig> It is compiled and linked in, but I'm not sure how many of
Craig> its functions are called. Andy would probably have a
Craig> better idea on that.
Could any of you tell me how to distinguish NTFS from FAT partitions
both on Windows NT and Windows9[58] safely?
After a lot of clicking in MSDN I found
DeviceIoControl(BOOL DeviceIoControl(
(HANDLE) hDevice, // handle to device of interest
IOCTL_DISK_GET_PARTITION_INFO, // dwIoControlCode, control code
// of operation to perform
NULL, // lpInBuffer is not used; must be NULL
0, // nInBufferSize is not used; must be zero
(LPVOID) lpOutBuffer, // pointer to output buffer
(DWORD) nOutBufferSize, // size, in bytes, of lpOutBuffer
(LPDWORD) lpBytesReturned, // pointer to variable to receive
// output byte count
(LPOVERLAPPED) lpOverlapped // pointer to OVERLAPPED structure
// for asynchronous operation
);
which is appealing at first glance.
However, hDevice can only be opened directly with CreateFile on NT.
95 is incompatible and requires dealing with VxDs.
Am I on the right track?
What would be the simplest working way to tell apart NTFS and FAT
files on the Windows NT, 95, 98 kindred?
Thanks for any help!
Adrian