diff options
author | vincentdarley <vincentdarley> | 2001-10-29 15:02:44 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley> | 2001-10-29 15:02:44 (GMT) |
commit | 17543c4edf712509641c3f7b8bf44a63b172818e (patch) | |
tree | 6482def417003125e4736466eb3b7797f8d982c1 /win | |
parent | d165eb244ad4b9050dee074a00ecdda41df575ed (diff) | |
download | tcl-17543c4edf712509641c3f7b8bf44a63b172818e.zip tcl-17543c4edf712509641c3f7b8bf44a63b172818e.tar.gz tcl-17543c4edf712509641c3f7b8bf44a63b172818e.tar.bz2 |
win fs fixes
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWin32Dll.c | 6 | ||||
-rw-r--r-- | win/tclWinFile.c | 52 | ||||
-rw-r--r-- | win/tclWinInt.h | 5 |
3 files changed, 49 insertions, 14 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index ed4051a..ce9bbcb 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWin32Dll.c,v 1.9 2000/03/31 08:52:30 hobbs Exp $ + * RCS: @(#) $Id: tclWin32Dll.c,v 1.10 2001/10/29 15:02:44 vincentdarley Exp $ */ #include "tclWinInt.h" @@ -78,6 +78,8 @@ static TclWinProcs asciiProcs = { 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 @@ static TclWinProcs unicodeProcs = { 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; diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 67d1385..cc5e9c5 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.17 2001/09/27 00:36:16 dgp Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.18 2001/10/29 15:02:44 vincentdarley Exp $ */ #include "tclWinInt.h" @@ -339,8 +339,6 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types) typeOk = 0; } } else { - struct stat buf; - if (attr & FILE_ATTRIBUTE_HIDDEN) { /* If invisible */ if ((types->perm == 0) || @@ -369,12 +367,16 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types) } } if (typeOk && types->type != 0) { - if (types->perm == 0) { - /* We haven't yet done a stat on the file */ - if (NativeStat(nativeName, &buf) != 0) { - /* Posix error occurred */ - typeOk = 0; - } + struct stat buf; + + if (NativeStat(nativeName, &buf) != 0) { + /* + * Posix error occurred, either the file + * has disappeared, or there is some other + * strange error. In any case we don't + * return this file. + */ + typeOk = 0; } if (typeOk) { /* @@ -791,7 +793,7 @@ TclpGetCwd(interp, bufferPtr) } /* - * Watch for the wierd Windows c:\\UNC syntax. + * Watch for the weird Windows c:\\UNC syntax. */ if (tclWinProcs->useWide) { @@ -831,6 +833,7 @@ TclpObjStat(pathPtr, statPtr) 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 @@ -842,7 +845,8 @@ TclpObjStat(pathPtr, statPtr) 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 @@ -883,14 +887,19 @@ NativeStat(nativePath, statPtr) 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; CONST char *fullPath; int dev, mode; +#ifdef OLD_API handle = (*tclWinProcs->findFirstFileProc)(nativePath, &data); if (handle == INVALID_HANDLE_VALUE) { /* @@ -914,7 +923,15 @@ NativeStat(nativePath, statPtr) } else { FindClose(handle); } - +#else + if((*tclWinProcs->getFileAttributesExProc)(nativePath, + GetFileExInfoStandard, + &data) != TRUE) { + Tcl_SetErrno(ENOENT); + return -1; + } +#endif + (*tclWinProcs->getFullPathNameProc)(nativePath, MAX_PATH, nativeFullPath, &nativePart); @@ -959,7 +976,11 @@ NativeStat(nativePath, statPtr) } 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)) { @@ -981,10 +1002,17 @@ NativeStat(nativePath, statPtr) 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; } diff --git a/win/tclWinInt.h b/win/tclWinInt.h index 287ecb3..199942f 100644 --- a/win/tclWinInt.h +++ b/win/tclWinInt.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinInt.h,v 1.11 2001/09/10 17:17:42 andreas_kupries Exp $ + * RCS: @(#) $Id: tclWinInt.h,v 1.12 2001/10/29 15:02:44 vincentdarley Exp $ */ #ifndef _TCLWININT @@ -89,6 +89,9 @@ typedef struct TclWinProcs { 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; |