| 8738 | }; |
| 8739 | |
| 8740 | ResultType Line::FileSetTime(LPTSTR aYYYYMMDD, LPTSTR aFilePattern, TCHAR aWhichTime |
| 8741 | , FileLoopModeType aOperateOnFolders, bool aDoRecurse) |
| 8742 | // Returns the number of files and folders that could not be changed due to an error. |
| 8743 | { |
| 8744 | // Related to the comment at the top: Since the script subroutine that resulted in the call to |
| 8745 | // this function can be interrupted during our MsgSleep(), make a copy of any params that might |
| 8746 | // currently point directly to the deref buffer. This is done because their contents might |
| 8747 | // be overwritten by the interrupting subroutine: |
| 8748 | TCHAR yyyymmdd[64]; // Even do this one since its value is passed recursively in calls to self. |
| 8749 | tcslcpy(yyyymmdd, aYYYYMMDD, _countof(yyyymmdd)); |
| 8750 | |
| 8751 | FileSetTimeData callbackData; |
| 8752 | callbackData.WhichTime = aWhichTime; |
| 8753 | FILETIME ft; |
| 8754 | if (*yyyymmdd) |
| 8755 | { |
| 8756 | if ( !YYYYMMDDToFileTime(yyyymmdd, ft) // Convert the arg into the time struct as local (non-UTC) time. |
| 8757 | || !LocalFileTimeToFileTime(&ft, &callbackData.Time) ) // Convert from local to UTC. |
| 8758 | { |
| 8759 | // Invalid parameters are the only likely cause of this condition. |
| 8760 | return LineError(ERR_PARAM1_INVALID, FAIL_OR_OK, aYYYYMMDD); |
| 8761 | } |
| 8762 | } |
| 8763 | else // User wants to use the current time (i.e. now) as the new timestamp. |
| 8764 | GetSystemTimeAsFileTime(&callbackData.Time); |
| 8765 | |
| 8766 | if (!*aFilePattern) |
| 8767 | return LineError(ERR_PARAM2_INVALID, FAIL_OR_OK); |
| 8768 | |
| 8769 | FilePatternApply(aFilePattern, aOperateOnFolders, aDoRecurse, FileSetTimeCallback, &callbackData); |
| 8770 | return OK; |
| 8771 | } |
| 8772 | |
| 8773 | BOOL FileSetTimeCallback(LPTSTR aFilename, WIN32_FIND_DATA &aFile, void *aCallbackData) |
| 8774 | { |
nothing calls this directly
no test coverage detected