Changes in file copy time between different file systems

Source: Internet
Author: User

Author: eaglet

Reprinted please indicate the source

My system needs to compare the file time and size to determine whether the two files are the same, but during the running process, it is often found that the file time is inexplicably modified for 1-2 seconds. I have not studied this problem carefully and thought it was a bug of Microsoft. I have not found this problem clearly until recently. The system often downloads the same files from the server. I carefully studied this issue today and found that it is not a problem with Microsoft operating systems, but a problem with file system design.

Go straight to the topic

The FAT32 file system uses the FAT table (File Allocation Table) to store the file index information. To minimize the space occupied by each file in the FAT table, the FAT32 file system limits the file size to less than 4 GB, the file time precision to 2 seconds, and is aligned with an even number. The NTFS file system uses the MFT table (master file table) to store file metadata. This master file table is equivalent to a small database and can store more metadata. Therefore, whether the NTFS file system is the file size or the file time precision is much higher than that of FAT32. NTFS, the file precision is 100ns.

Because the file precision of the two file systems is different, if we copy the file from the NTFS file system to the FAT32 file, due to different time precision, the file time will be forcibly aligned with an even number.

 

NTFS time: 7 hours 31 min 0 sec 000 ms.
FAT time: 7 hours 31 min 0 sec 000 ms.

 
NTFS time: 7 hours 31 min 0 sec 001 ms.
FAT32 time: 7 hours 31 min 2 sec 000 ms.

NTFS time: 7 hours 31 min 1 sec 000 ms.
FAT32 time: 7 hours 31 min 2 sec 000 ms.

 
NTFS time: 7 hours 31 min 1 sec 999 ms.
FAT32 time: 7 hours 31 min 2 sec 000 ms.

 

From the above example, we can see that NTFS to FAT32, the file time will be 2 seconds at most.

If we need to determine whether the file is the same through the file time in the program, we must take into account the time error of the two file systems, otherwise the system will be wrong. In addition, it is better to use MD5 to determine whether the files are the same, but for large files, the MD5 computing time will be relatively long.

Refer:

Http://support.microsoft.com/kb/127830

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.