Attachment "winStat.patch" to
ticket [219258ffff]
added by
vincentdarley
2001-09-20 21:15:59.
Index: tclWin32Dll.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWin32Dll.c,v
retrieving revision 1.9
diff -u -r1.9 tclWin32Dll.c
--- tclWin32Dll.c 2000/03/31 08:52:30 1.9
+++ tclWin32Dll.c 2001/09/20 14:15:08
@@ -78,6 +78,8 @@
WCHAR *, TCHAR **)) SearchPathA,
(BOOL (WINAPI *)(CONST TCHAR *)) SetCurrentDirectoryA,
(BOOL (WINAPI *)(CONST TCHAR *, DWORD)) SetFileAttributesA,
+ (BOOL (WINAPI *)(CONST TCHAR *, GET_FILEEX_INFO_LEVELS,
+ LPVOID)) GetFileAttributesExA,
};
static TclWinProcs unicodeProcs = {
@@ -115,6 +117,8 @@
WCHAR *, TCHAR **)) SearchPathW,
(BOOL (WINAPI *)(CONST TCHAR *)) SetCurrentDirectoryW,
(BOOL (WINAPI *)(CONST TCHAR *, DWORD)) SetFileAttributesW,
+ (BOOL (WINAPI *)(CONST TCHAR *, GET_FILEEX_INFO_LEVELS,
+ LPVOID)) GetFileAttributesExW,
};
TclWinProcs *tclWinProcs;
Index: tclWinFile.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinFile.c,v
retrieving revision 1.15
diff -u -r1.15 tclWinFile.c
--- tclWinFile.c 2001/09/10 17:17:41 1.15
+++ tclWinFile.c 2001/09/20 14:15:09
@@ -790,7 +790,7 @@
}
/*
- * Watch for the wierd Windows c:\\UNC syntax.
+ * Watch for the weird Windows c:\\UNC syntax.
*/
if (tclWinProcs->useWide) {
@@ -830,6 +830,7 @@
Tcl_Obj *pathPtr; /* Path of file to stat */
struct stat *statPtr; /* Filled with results of stat call. */
{
+#ifdef OLD_API
Tcl_Obj *transPtr;
/*
* Eliminate file names containing wildcard characters, or subsequent
@@ -841,7 +842,8 @@
Tcl_SetErrno(ENOENT);
return -1;
}
-
+#endif
+
/*
* Ensure correct file sizes by forcing the OS to write any
* pending data to disk. This is done only for channels which are
@@ -882,14 +884,19 @@
struct stat *statPtr; /* Filled with results of stat call. */
{
Tcl_DString ds;
+#ifdef OLD_API
WIN32_FIND_DATAT data;
HANDLE handle;
+#else
+ WIN32_FILE_ATTRIBUTE_DATA data;
+#endif
DWORD attr;
WCHAR nativeFullPath[MAX_PATH];
TCHAR *nativePart;
char *fullPath;
int dev, mode;
+#ifdef OLD_API
handle = (*tclWinProcs->findFirstFileProc)(nativePath, &data);
if (handle == INVALID_HANDLE_VALUE) {
/*
@@ -913,7 +920,15 @@
} else {
FindClose(handle);
}
-
+#else
+ if((*tclWinProcs->getFileAttributesExProc)(nativePath,
+ GetFileExInfoStandard,
+ &data) != TRUE) {
+ Tcl_SetErrno(ENOENT);
+ return -1;
+ }
+#endif
+
(*tclWinProcs->getFullPathNameProc)(nativePath, MAX_PATH, nativeFullPath,
&nativePart);
@@ -958,7 +973,11 @@
}
Tcl_DStringFree(&ds);
+#ifdef OLD_API
attr = data.a.dwFileAttributes;
+#else
+ attr = data.dwFileAttributes;
+#endif
mode = (attr & FILE_ATTRIBUTE_DIRECTORY) ? S_IFDIR | S_IEXEC : S_IFREG;
mode |= (attr & FILE_ATTRIBUTE_READONLY) ? S_IREAD : S_IREAD | S_IWRITE;
if (NativeIsExec(nativePath)) {
@@ -980,10 +999,17 @@
statPtr->st_uid = 0;
statPtr->st_gid = 0;
statPtr->st_rdev = (dev_t) dev;
+#ifdef OLD_API
statPtr->st_size = data.a.nFileSizeLow;
statPtr->st_atime = ToCTime(data.a.ftLastAccessTime);
statPtr->st_mtime = ToCTime(data.a.ftLastWriteTime);
statPtr->st_ctime = ToCTime(data.a.ftCreationTime);
+#else
+ statPtr->st_size = data.nFileSizeLow;
+ statPtr->st_atime = ToCTime(data.ftLastAccessTime);
+ statPtr->st_mtime = ToCTime(data.ftLastWriteTime);
+ statPtr->st_ctime = ToCTime(data.ftCreationTime);
+#endif
return 0;
}
Index: tclWinInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinInt.h,v
retrieving revision 1.11
diff -u -r1.11 tclWinInt.h
--- tclWinInt.h 2001/09/10 17:17:42 1.11
+++ tclWinInt.h 2001/09/20 14:15:09
@@ -89,6 +89,9 @@
CONST TCHAR *, DWORD, WCHAR *, TCHAR **);
BOOL (WINAPI *setCurrentDirectoryProc)(CONST TCHAR *);
BOOL (WINAPI *setFileAttributesProc)(CONST TCHAR *, DWORD);
+ BOOL (WINAPI *getFileAttributesExProc)(CONST TCHAR *,
+ GET_FILEEX_INFO_LEVELS, LPVOID);
+
} TclWinProcs;
EXTERN TclWinProcs *tclWinProcs;