diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2006-10-01 13:17:34 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2006-10-01 13:17:34 (GMT) |
commit | 323746151e57849e59cc1f7fd62b0a3bc1fd008a (patch) | |
tree | b15ff467a4d2d1c525734eadd41b038813577977 /win | |
parent | cdfa56a859371e243fb5fac517a2cc6196e48b7c (diff) | |
download | tcl-323746151e57849e59cc1f7fd62b0a3bc1fd008a.zip tcl-323746151e57849e59cc1f7fd62b0a3bc1fd008a.tar.gz tcl-323746151e57849e59cc1f7fd62b0a3bc1fd008a.tar.bz2 |
Backported fix for bug #1420432 (cannot set mtime for directories on windows).
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinFile.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 507c2a1..7f1e12a 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFile.c,v 1.44.2.15 2006/03/19 22:47:30 vincentdarley Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.44.2.16 2006/10/01 13:17:34 patthoyts Exp $ */ //#define _WIN32_WINNT 0x0500 @@ -2635,20 +2635,30 @@ TclpUtime( { int res = 0; HANDLE fileHandle; + CONST TCHAR *native; + DWORD attr = 0; + DWORD flags = FILE_ATTRIBUTE_NORMAL; FILETIME lastAccessTime, lastModTime; FromCTime(tval->actime, &lastAccessTime); FromCTime(tval->modtime, &lastModTime); + native = (CONST TCHAR *)Tcl_FSGetNativePath(pathPtr); + + attr = (*tclWinProcs->getFileAttributesProc)(native); + + if (attr != INVALID_FILE_ATTRIBUTES && attr & FILE_ATTRIBUTE_DIRECTORY) { + flags = FILE_FLAG_BACKUP_SEMANTICS; + } + /* * We use the native APIs (not 'utime') because there are some daylight * savings complications that utime gets wrong. */ fileHandle = (tclWinProcs->createFileProc) ( - (CONST TCHAR *) Tcl_FSGetNativePath(pathPtr), - FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL); + native, FILE_WRITE_ATTRIBUTES, 0, NULL, + OPEN_EXISTING, flags, NULL); if (fileHandle == INVALID_HANDLE_VALUE || !SetFileTime(fileHandle, NULL, &lastAccessTime, &lastModTime)) { |