Windows 兼容文件系统的文件时间分辨率
Windows-compatible filesystems' file time resolutions
我正在尝试编写一个文件同步应用程序,它可以在使用任何兼容文件系统的不同 Windows 机器上普遍使用。我需要在文件在两台机器之间同步到特定粒度之前将文件的时间戳标准化,以便在同步工作完成后文件在两台不同的机器上看起来是时间戳相同的。出于我的目的,我只需要规范化文件时间戳。对于每个要同步的文件,我只需要归一化最后写入时间和创建时间即可。
MSDN has this to say about the FILETIME structure and its resolution:
Not all file systems can record creation and last access time and not
all file systems record them in the same manner. For example, on NT
FAT, create time has a resolution of 10 milliseconds, write time has a
resolution of 2 seconds, and access time has a resolution of 1 day
(really, the access date). On NTFS, access time has a resolution of 1
hour. Therefore, the GetFileTime function may not return the same file
time information set using the SetFileTime function. Furthermore, FAT
records times on disk in local time. However, NTFS records times on
disk in UTC. For more information, see File Times.
Windows makes use of the FAT, NTFS, exFAT, Live File System and ReFS
file systems (the last of these is only supported and usable in
Windows Server 2012; Windows cannot boot from it).
所以,换句话说,我的问题可以概括为:
在 FAT、NTFS、exFAT、实时文件系统和 ReFS 的分组中,
- 对于文件的最后写入时间,Windows 中哪个分辨率最差?
- 哪个文件的创建时间 Windows 分辨率最差?
我已尝试搜索,但找不到有关这些不同 Windows 兼容文件系统之间文件时间戳解析差异的详细信息。
我通过查看每个文件系统的文章并查找其 日期分辨率.
找到了我的答案 here
FAT8
不记录日期并且在 Windows 中不受支持。
FAT12、FAT16、FAT16B 和 FAT32
其中一些在 Windows 中不受支持。
- 最后修改时间:2 秒
- 创建时间:10 毫秒
- 访问时间:1 天
- 删除时间:2秒
exFAT
所有记录 10 毫秒。
NTFS
所有记录 100 ns。
实时文件系统 (UDF)
所有记录 1 微秒。
ReFS
无法找到解决方案的详细信息,但它非常现代,所以我假设大多数最坏的情况都在上面,而且目前没有多少人会使用它。或许有人在发现后可以美化这个 post。
所以,回答问题:
1.对于文件的最后一次写入时间,哪个在 Windows 中具有最差的分辨率?
2 秒,FAT 文件系统。
2。在文件创建时间 Windows 中,哪个分辨率最差?
10 毫秒,也是 FAT 文件系统。
我正在尝试编写一个文件同步应用程序,它可以在使用任何兼容文件系统的不同 Windows 机器上普遍使用。我需要在文件在两台机器之间同步到特定粒度之前将文件的时间戳标准化,以便在同步工作完成后文件在两台不同的机器上看起来是时间戳相同的。出于我的目的,我只需要规范化文件时间戳。对于每个要同步的文件,我只需要归一化最后写入时间和创建时间即可。
MSDN has this to say about the FILETIME structure and its resolution:
Not all file systems can record creation and last access time and not all file systems record them in the same manner. For example, on NT FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). On NTFS, access time has a resolution of 1 hour. Therefore, the GetFileTime function may not return the same file time information set using the SetFileTime function. Furthermore, FAT records times on disk in local time. However, NTFS records times on disk in UTC. For more information, see File Times.
Windows makes use of the FAT, NTFS, exFAT, Live File System and ReFS file systems (the last of these is only supported and usable in Windows Server 2012; Windows cannot boot from it).
所以,换句话说,我的问题可以概括为:
在 FAT、NTFS、exFAT、实时文件系统和 ReFS 的分组中,
- 对于文件的最后写入时间,Windows 中哪个分辨率最差?
- 哪个文件的创建时间 Windows 分辨率最差?
我已尝试搜索,但找不到有关这些不同 Windows 兼容文件系统之间文件时间戳解析差异的详细信息。
我通过查看每个文件系统的文章并查找其 日期分辨率.
找到了我的答案 hereFAT8
不记录日期并且在 Windows 中不受支持。
FAT12、FAT16、FAT16B 和 FAT32
其中一些在 Windows 中不受支持。
- 最后修改时间:2 秒
- 创建时间:10 毫秒
- 访问时间:1 天
- 删除时间:2秒
exFAT
所有记录 10 毫秒。
NTFS
所有记录 100 ns。
实时文件系统 (UDF)
所有记录 1 微秒。
ReFS
无法找到解决方案的详细信息,但它非常现代,所以我假设大多数最坏的情况都在上面,而且目前没有多少人会使用它。或许有人在发现后可以美化这个 post。
所以,回答问题:
1.对于文件的最后一次写入时间,哪个在 Windows 中具有最差的分辨率?
2 秒,FAT 文件系统。
2。在文件创建时间 Windows 中,哪个分辨率最差?
10 毫秒,也是 FAT 文件系统。