diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2006-10-01 13:03:56 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2006-10-01 13:03:56 (GMT) |
commit | 1676722753b69ec304ed95a1d75b24501b5445a4 (patch) | |
tree | f900c081b3a0024359154f5e9e79527181cff93a /win/tclWinFile.c | |
parent | c66d63df2c14632d90b665b3e576bc44b18e627f (diff) | |
download | tcl-1676722753b69ec304ed95a1d75b24501b5445a4.zip tcl-1676722753b69ec304ed95a1d75b24501b5445a4.tar.gz tcl-1676722753b69ec304ed95a1d75b24501b5445a4.tar.bz2 |
bug #1420432 - file mtime fails for directories on windows
Diffstat (limited to 'win/tclWinFile.c')
-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 03ccf9d..ce4dae4 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.86 2006/08/29 00:36:57 coldstore Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.87 2006/10/01 13:03:56 patthoyts Exp $ */ /* #define _WIN32_WINNT 0x0500 */ @@ -3355,10 +3355,21 @@ 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 @@ -3366,9 +3377,8 @@ TclpUtime( */ 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)) { |