summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--tests/cmdAH.test17
-rw-r--r--win/tclWinFile.c18
3 files changed, 35 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 4f13450..6911e60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-01 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * win/tclWinFile.c: Backported fix for bug #1420432 (cannot set
+ * tests/cmdAH.test: mtime for directories on windows).
+
2006-09-30 Miguel Sofer <msofer@users.sf.net>
* generic/tclUtil.c (Tcl_SplitList): optimisation, [Patch 1344747]
diff --git a/tests/cmdAH.test b/tests/cmdAH.test
index 6b0e053..646dd20 100644
--- a/tests/cmdAH.test
+++ b/tests/cmdAH.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: cmdAH.test,v 1.30.2.5 2005/11/15 16:41:41 kennykb Exp $
+# RCS: @(#) $Id: cmdAH.test,v 1.30.2.6 2006/10/01 13:17:34 patthoyts Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -1449,6 +1449,21 @@ test cmdAH-24.12 {Tcl_FileObjCmd: mtime and daylight savings} {
expr {$newmtime == $time ? 1 : "$newmtime != $time"}
} {1}
+# bug 1420432: setting mtime fails for directories on windows.
+test cmdAH-24.13 {Tcl_FileObjCmd: directory mtime} {
+ set dirname [file join [temporaryDirectory] tmp[pid]]
+ file delete -force $dirname
+ file mkdir $dirname
+ set res [catch {
+ set old [file mtime $dirname]
+ file mtime $dirname 0
+ set new [file mtime $dirname]
+ list $new [expr {$old != $new}]
+ } err]
+ file delete -force $dirname
+ list $res $err
+} {0 {0 1}}
+
# owned
test cmdAH-25.1 {Tcl_FileObjCmd: owned} {
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)) {