| 8771 | } |
| 8772 | |
| 8773 | BOOL FileSetTimeCallback(LPTSTR aFilename, WIN32_FIND_DATA &aFile, void *aCallbackData) |
| 8774 | { |
| 8775 | HANDLE hFile; |
| 8776 | // Open existing file. |
| 8777 | // FILE_FLAG_NO_BUFFERING might improve performance because all we're doing is |
| 8778 | // changing one of the file's attributes. FILE_FLAG_BACKUP_SEMANTICS must be |
| 8779 | // used, otherwise changing the time of a directory under NT and beyond will |
| 8780 | // not succeed. Win95 (not sure about Win98/Me) does not support this, but it |
| 8781 | // should be harmless to specify it even if the OS is Win95: |
| 8782 | hFile = CreateFile(aFilename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE |
| 8783 | , (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING |
| 8784 | , FILE_FLAG_NO_BUFFERING | FILE_FLAG_BACKUP_SEMANTICS, NULL); |
| 8785 | if (hFile == INVALID_HANDLE_VALUE) |
| 8786 | { |
| 8787 | g->LastError = GetLastError(); |
| 8788 | return FALSE; |
| 8789 | } |
| 8790 | |
| 8791 | BOOL success; |
| 8792 | FileSetTimeData &a = *(FileSetTimeData *)aCallbackData; |
| 8793 | switch (ctoupper(a.WhichTime)) |
| 8794 | { |
| 8795 | case 'C': // File's creation time. |
| 8796 | success = SetFileTime(hFile, &a.Time, NULL, NULL); |
| 8797 | break; |
| 8798 | case 'A': // File's last access time. |
| 8799 | success = SetFileTime(hFile, NULL, &a.Time, NULL); |
| 8800 | break; |
| 8801 | default: // 'M', unspecified, or some other value. Use the file's modification time. |
| 8802 | success = SetFileTime(hFile, NULL, NULL, &a.Time); |
| 8803 | } |
| 8804 | if (!success) |
| 8805 | g->LastError = GetLastError(); |
| 8806 | CloseHandle(hFile); |
| 8807 | return success; |
| 8808 | } |
| 8809 | |
| 8810 | |
| 8811 |
nothing calls this directly
no test coverage detected