summaryrefslogtreecommitdiffstats
path: root/win/tclWinFile.c
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2006-10-01 13:17:34 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2006-10-01 13:17:34 (GMT)
commit90cf19d1e8047062753c6dcb127807aec08760b7 (patch)
treeb15ff467a4d2d1c525734eadd41b038813577977 /win/tclWinFile.c
parent6038a3e7e943a56a3a1d383b9048d2785d4171f3 (diff)
downloadtcl-90cf19d1e8047062753c6dcb127807aec08760b7.zip
tcl-90cf19d1e8047062753c6dcb127807aec08760b7.tar.gz
tcl-90cf19d1e8047062753c6dcb127807aec08760b7.tar.bz2
Backported fix for bug #1420432 (cannot set mtime for directories on windows).
Diffstat (limited to 'win/tclWinFile.c')
-rw-r--r--win/tclWinFile.c18
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)) {