windows - NTFS Filesystem Time -
I tested it on Windows XP.
If I do
- Write the file.
- Close the file. (Then, the last time of the file has changed)
But if
Edit :
Wstring filename = L "D: \\ testfile.txt"; Handle H = Make FileW (Filename. Cstr), generic_write | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, CREATE_ALWAYS, 0, 0); FILETIME ft1, ft2, ft3; If (GetFileTime (H, FT1, and FT2, and FT3)) {return; } Std :: cout & lt; & Lt; Ft3.dwHighDateTime & lt; & Lt; Std :: endl & lt; & Lt; Ft3.dwLowDateTime & lt; & Lt; Std :: endl; Ft1.dwLowDateTime = 1000000; If (Setfiletime (H, FT1, and FT1, and FT1)) {return; } If (GetFileTime (H, FT1, & FT2, and FT3)) {return; } Std :: cout & lt; & Lt; Ft3.dwHighDateTime & lt; & Lt; Std :: endl & lt; & Lt; Ft3.dwLowDateTime & lt; & Lt; Std :: endl; Sleep (5000); TCHR buffer [] = L "test 1234567890 test 1234567890 test 1234567890 test 1234567890 test 1234567890 \ r \ n"; Write DWORDbits = 0; BOOL fOk = WriteFile (H, buffer, size (buffer), and writebays, 0); If (! FOK) {return; } If (written! = Size (buffer)) {return; } If (GetFileTime (H, FT1, & FT2, and FT3)) {return; } Std :: cout & lt; & Lt; Ft3.dwHighDateTime & lt; & Lt; Std :: endl & lt; & Lt; Ft3.dwLowDateTime & lt; & Lt; Std :: endl; CloseHandle (h); H = CreateFileW (fileName.c_str), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, 0, 0); If (GetFileTime (H, FT1, and FT2, and FT3)) {return; } Std :: cout & lt; & Lt; Ft3.dwHighDateTime & lt; & Lt; Std :: endl & lt; & Lt; Ft3.dwLowDateTime & lt; & Lt; Std :: endl; CloseHandle (h); DeleteFile (fileName.c_str ());
Can you explain to me about this? Thank you.
Try calling FlushFileBuffers (h)
to change time stamps Use the FILE_FLAG_WRITE_THROUGH
and FILE_FLAG_NO_BUFFERING
flag while opening or after opening the file. See in:
A write request through FILE_FLAG_WRITE_THROUGH also causes NTFS to flush any metadata changes, such as time stamp updates or rename operations, which are requested The result of processing is For this reason, the FILE_FLAG_WRITE_THROUGH flag is often used with the FILE_FLAG_NO_BUFFERING flag as a replacement for calling the FluffFilf buffers function after each write, which can cause unnecessary performance penalties. Using these flags to avoid those penalties For general information about caching files and metadata, see file caching.
Comments
Post a Comment