diff options
author | nijtmans <nijtmans> | 2010-10-12 10:21:55 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2010-10-12 10:21:55 (GMT) |
commit | 88ac6d1bd8bf253aaca06731296ed6c96410decb (patch) | |
tree | b047c3aa39ae420af8227427ce5dced10f901429 /win/tclWinFCmd.c | |
parent | b344e4333e68bd8722897e5bf08a6f2711e6cdbd (diff) | |
download | tcl-88ac6d1bd8bf253aaca06731296ed6c96410decb.zip tcl-88ac6d1bd8bf253aaca06731296ed6c96410decb.tar.gz tcl-88ac6d1bd8bf253aaca06731296ed6c96410decb.tar.bz2 |
Eliminate many tclWinProcs-> indirect calls, which are no longer needed.
Fix some MSVC 6.0 warnings
Diffstat (limited to 'win/tclWinFCmd.c')
-rw-r--r-- | win/tclWinFCmd.c | 153 |
1 files changed, 75 insertions, 78 deletions
diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index 47c1b09..a35cc3b 100644 --- a/win/tclWinFCmd.c +++ b/win/tclWinFCmd.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: tclWinFCmd.c,v 1.68 2010/09/21 21:50:35 nijtmans Exp $ + * RCS: @(#) $Id: tclWinFCmd.c,v 1.69 2010/10/12 10:21:55 nijtmans Exp $ */ #include "tclWinInt.h" @@ -277,7 +277,7 @@ DoRenameFile( [registration] "m" (registration), [nativeDst] "m" (nativeDst), [nativeSrc] "m" (nativeSrc), - [moveFile] "r" (tclWinProcs->moveFileProc) + [moveFile] "r" (MoveFile) : "%eax", "%ebx", "%ecx", "%edx", "memory" ); @@ -288,7 +288,7 @@ DoRenameFile( #ifndef HAVE_NO_SEH __try { #endif - if ((*tclWinProcs->moveFileProc)(nativeSrc, nativeDst) != FALSE) { + if ((*MoveFile)(nativeSrc, nativeDst) != FALSE) { retval = TCL_OK; } #ifndef HAVE_NO_SEH @@ -302,10 +302,10 @@ DoRenameFile( TclWinConvertError(GetLastError()); - srcAttr = tclWinProcs->getFileAttributesProc(nativeSrc); - dstAttr = tclWinProcs->getFileAttributesProc(nativeDst); + srcAttr = GetFileAttributes(nativeSrc); + dstAttr = GetFileAttributes(nativeDst); if (srcAttr == 0xffffffff) { - if (tclWinProcs->getFullPathNameProc(nativeSrc, 0, NULL, + if (GetFullPathName(nativeSrc, 0, NULL, NULL) >= MAX_PATH) { errno = ENAMETOOLONG; return TCL_ERROR; @@ -313,7 +313,7 @@ DoRenameFile( srcAttr = 0; } if (dstAttr == 0xffffffff) { - if (tclWinProcs->getFullPathNameProc(nativeDst, 0, NULL, + if (GetFullPathName(nativeDst, 0, NULL, NULL) >= MAX_PATH) { errno = ENAMETOOLONG; return TCL_ERROR; @@ -336,21 +336,21 @@ DoRenameFile( Tcl_DString srcString, dstString; const char *src, *dst; - size = tclWinProcs->getFullPathNameProc(nativeSrc, MAX_PATH, + size = GetFullPathName(nativeSrc, MAX_PATH, nativeSrcPath, &nativeSrcRest); if ((size == 0) || (size > MAX_PATH)) { return TCL_ERROR; } - size = tclWinProcs->getFullPathNameProc(nativeDst, MAX_PATH, + size = GetFullPathName(nativeDst, MAX_PATH, nativeDstPath, &nativeDstRest); if ((size == 0) || (size > MAX_PATH)) { return TCL_ERROR; } - tclWinProcs->charLowerProc(nativeSrcPath); - tclWinProcs->charLowerProc(nativeDstPath); + CharLower(nativeSrcPath); + CharLower(nativeDstPath); - src = tclWinProcs->tchar2utf(nativeSrcPath, -1, &srcString); - dst = tclWinProcs->tchar2utf(nativeDstPath, -1, &dstString); + src = Tcl_WinTCharToUtf(nativeSrcPath, -1, &srcString); + dst = Tcl_WinTCharToUtf(nativeDstPath, -1, &dstString); /* * Check whether the destination path is actually inside the @@ -429,7 +429,7 @@ DoRenameFile( * directory back, for completeness. */ - if (tclWinProcs->moveFileProc(nativeSrc, + if (MoveFile(nativeSrc, nativeDst) != FALSE) { return TCL_OK; } @@ -440,8 +440,8 @@ DoRenameFile( */ TclWinConvertError(GetLastError()); - tclWinProcs->createDirectoryProc(nativeDst, NULL); - tclWinProcs->setFileAttributesProc(nativeDst, dstAttr); + CreateDirectory(nativeDst, NULL); + SetFileAttributes(nativeDst, dstAttr); if (Tcl_GetErrno() == EACCES) { /* * Decode the EACCES to a more meaningful error. @@ -470,7 +470,7 @@ DoRenameFile( int result, size; TCHAR tempBuf[MAX_PATH]; - size = tclWinProcs->getFullPathNameProc(nativeDst, MAX_PATH, + size = GetFullPathName(nativeDst, MAX_PATH, tempBuf, &nativeRest); if ((size == 0) || (size > MAX_PATH) || (nativeRest == NULL)) { return TCL_ERROR; @@ -480,7 +480,7 @@ DoRenameFile( result = TCL_ERROR; nativePrefix = (TCHAR *) L"tclr"; - if (tclWinProcs->getTempFileNameProc(nativeTmp, nativePrefix, + if (GetTempFileName(nativeTmp, nativePrefix, 0, tempBuf) != 0) { /* * Strictly speaking, need the following DeleteFile and @@ -489,19 +489,16 @@ DoRenameFile( * same temp file. */ - nativeTmp = (TCHAR *) tempBuf; - tclWinProcs->deleteFileProc(nativeTmp); - if (tclWinProcs->moveFileProc(nativeDst, - nativeTmp) != FALSE) { - if (tclWinProcs->moveFileProc(nativeSrc, - nativeDst) != FALSE) { - tclWinProcs->setFileAttributesProc(nativeTmp, - FILE_ATTRIBUTE_NORMAL); - tclWinProcs->deleteFileProc(nativeTmp); + nativeTmp = tempBuf; + DeleteFile(nativeTmp); + if (MoveFile(nativeDst, nativeTmp) != FALSE) { + if (MoveFile(nativeSrc, nativeDst) != FALSE) { + SetFileAttributes(nativeTmp, FILE_ATTRIBUTE_NORMAL); + DeleteFile(nativeTmp); return TCL_OK; } else { - tclWinProcs->deleteFileProc(nativeDst); - tclWinProcs->moveFileProc(nativeTmp, nativeDst); + DeleteFile(nativeDst); + MoveFile(nativeTmp, nativeDst); } } @@ -668,7 +665,7 @@ DoCopyFile( [registration] "m" (registration), [nativeDst] "m" (nativeDst), [nativeSrc] "m" (nativeSrc), - [copyFile] "r" (tclWinProcs->copyFileProc) + [copyFile] "r" (CopyFile) : "%eax", "%ebx", "%ecx", "%edx", "memory" ); @@ -679,7 +676,7 @@ DoCopyFile( #ifndef HAVE_NO_SEH __try { #endif - if ((*tclWinProcs->copyFileProc)(nativeSrc, nativeDst, 0) != FALSE) { + if (CopyFile(nativeSrc, nativeDst, 0) != FALSE) { retval = TCL_OK; } #ifndef HAVE_NO_SEH @@ -699,8 +696,8 @@ DoCopyFile( if (Tcl_GetErrno() == EACCES) { DWORD srcAttr, dstAttr; - srcAttr = tclWinProcs->getFileAttributesProc(nativeSrc); - dstAttr = tclWinProcs->getFileAttributesProc(nativeDst); + srcAttr = GetFileAttributes(nativeSrc); + dstAttr = GetFileAttributes(nativeDst); if (srcAttr != 0xffffffff) { if (dstAttr == 0xffffffff) { dstAttr = 0; @@ -716,9 +713,9 @@ DoCopyFile( Tcl_SetErrno(EISDIR); } if (dstAttr & FILE_ATTRIBUTE_READONLY) { - tclWinProcs->setFileAttributesProc(nativeDst, + SetFileAttributes(nativeDst, dstAttr & ~((DWORD)FILE_ATTRIBUTE_READONLY)); - if (tclWinProcs->copyFileProc(nativeSrc, nativeDst, + if (CopyFile(nativeSrc, nativeDst, 0) != FALSE) { return TCL_OK; } @@ -729,7 +726,7 @@ DoCopyFile( */ TclWinConvertError(GetLastError()); - tclWinProcs->setFileAttributesProc(nativeDst, dstAttr); + SetFileAttributes(nativeDst, dstAttr); } } } @@ -785,13 +782,13 @@ TclpDeleteFile( return TCL_ERROR; } - if (tclWinProcs->deleteFileProc(path) != FALSE) { + if (DeleteFile(path) != FALSE) { return TCL_OK; } TclWinConvertError(GetLastError()); if (Tcl_GetErrno() == EACCES) { - attr = tclWinProcs->getFileAttributesProc(path); + attr = GetFileAttributes(path); if (attr != 0xffffffff) { if (attr & FILE_ATTRIBUTE_DIRECTORY) { if (attr & FILE_ATTRIBUTE_REPARSE_POINT) { @@ -812,21 +809,21 @@ TclpDeleteFile( Tcl_SetErrno(EISDIR); } else if (attr & FILE_ATTRIBUTE_READONLY) { - int res = tclWinProcs->setFileAttributesProc(path, + int res = SetFileAttributes(path, attr & ~((DWORD) FILE_ATTRIBUTE_READONLY)); if ((res != 0) && - (tclWinProcs->deleteFileProc(path) != FALSE)) { + (DeleteFile(path) != FALSE)) { return TCL_OK; } TclWinConvertError(GetLastError()); if (res != 0) { - tclWinProcs->setFileAttributesProc(path, attr); + SetFileAttributes(path, attr); } } } } else if (Tcl_GetErrno() == ENOENT) { - attr = tclWinProcs->getFileAttributesProc(path); + attr = GetFileAttributes(path); if (attr != 0xffffffff) { if (attr & FILE_ATTRIBUTE_DIRECTORY) { /* @@ -885,7 +882,7 @@ static int DoCreateDirectory( const TCHAR *nativePath) /* Pathname of directory to create (native). */ { - if (tclWinProcs->createDirectoryProc(nativePath, NULL) == 0) { + if (CreateDirectory(nativePath, NULL) == 0) { DWORD error = GetLastError(); TclWinConvertError(error); @@ -935,8 +932,8 @@ TclpObjCopyDirectory( return TCL_ERROR; } - tclWinProcs->utf2tchar(Tcl_GetString(normSrcPtr), -1, &srcString); - tclWinProcs->utf2tchar(Tcl_GetString(normDestPtr), -1, &dstString); + Tcl_WinUtfToTChar(Tcl_GetString(normSrcPtr), -1, &srcString); + Tcl_WinUtfToTChar(Tcl_GetString(normDestPtr), -1, &dstString); ret = TraverseWinTree(TraversalCopy, &srcString, &dstString, &ds); @@ -1008,7 +1005,7 @@ TclpObjRemoveDirectory( if (normPtr == NULL) { return TCL_ERROR; } - tclWinProcs->utf2tchar(Tcl_GetString(normPtr), -1, &native); + Tcl_WinUtfToTChar(Tcl_GetString(normPtr), -1, &native); ret = DoRemoveDirectory(&native, recursive, &ds); Tcl_DStringFree(&native); } else { @@ -1054,7 +1051,7 @@ DoRemoveJustDirectory( goto end; } - attr = tclWinProcs->getFileAttributesProc(nativePath); + attr = GetFileAttributes(nativePath); if (attr & FILE_ATTRIBUTE_REPARSE_POINT) { /* @@ -1068,7 +1065,7 @@ DoRemoveJustDirectory( * Ordinary directory. */ - if (tclWinProcs->removeDirectoryProc(nativePath) != FALSE) { + if (RemoveDirectory(nativePath) != FALSE) { return TCL_OK; } } @@ -1076,7 +1073,7 @@ DoRemoveJustDirectory( TclWinConvertError(GetLastError()); if (Tcl_GetErrno() == EACCES) { - attr = tclWinProcs->getFileAttributesProc(nativePath); + attr = GetFileAttributes(nativePath); if (attr != 0xffffffff) { if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) { /* @@ -1100,15 +1097,15 @@ DoRemoveJustDirectory( if (attr & FILE_ATTRIBUTE_READONLY) { attr &= ~FILE_ATTRIBUTE_READONLY; - if (tclWinProcs->setFileAttributesProc(nativePath, + if (SetFileAttributes(nativePath, attr) == FALSE) { goto end; } - if (tclWinProcs->removeDirectoryProc(nativePath) != FALSE) { + if (RemoveDirectory(nativePath) != FALSE) { return TCL_OK; } TclWinConvertError(GetLastError()); - tclWinProcs->setFileAttributesProc(nativePath, + SetFileAttributes(nativePath, attr | FILE_ATTRIBUTE_READONLY); } @@ -1176,7 +1173,7 @@ DoRemoveJustDirectory( end: if (errorPtr != NULL) { - tclWinProcs->tchar2utf(nativePath, -1, errorPtr); + Tcl_WinTCharToUtf(nativePath, -1, errorPtr); } return TCL_ERROR; @@ -1247,7 +1244,7 @@ TraverseWinTree( TCHAR *nativeSource, *nativeTarget, *nativeErrfile; int result, found, sourceLen, targetLen = 0, oldSourceLen, oldTargetLen; HANDLE handle; - WIN32_FIND_DATAT data; + WIN32_FIND_DATA data; nativeErrfile = NULL; result = TCL_OK; @@ -1258,7 +1255,7 @@ TraverseWinTree( (targetPtr == NULL ? NULL : Tcl_DStringValue(targetPtr)); oldSourceLen = Tcl_DStringLength(sourcePtr); - sourceAttr = tclWinProcs->getFileAttributesProc(nativeSource); + sourceAttr = GetFileAttributes(nativeSource); if (sourceAttr == 0xffffffff) { nativeErrfile = nativeSource; goto end; @@ -1285,7 +1282,7 @@ TraverseWinTree( Tcl_DStringSetLength(sourcePtr, Tcl_DStringLength(sourcePtr) - 1); nativeSource = (TCHAR *) Tcl_DStringValue(sourcePtr); - handle = tclWinProcs->findFirstFileProc(nativeSource, &data); + handle = FindFirstFile(nativeSource, &data); if (handle == INVALID_HANDLE_VALUE) { /* * Can't read directory. @@ -1318,11 +1315,11 @@ TraverseWinTree( } found = 1; - for (; found; found = tclWinProcs->findNextFileProc(handle, &data)) { + for (; found; found = FindNextFile(handle, &data)) { TCHAR *nativeName; int len; - WCHAR *wp = data.w.cFileName; + WCHAR *wp = data.cFileName; if (*wp == '.') { wp++; if (*wp == '.') { @@ -1332,8 +1329,8 @@ TraverseWinTree( continue; } } - nativeName = (TCHAR *) data.w.cFileName; - len = wcslen(data.w.cFileName) * sizeof(WCHAR); + nativeName = (TCHAR *) data.cFileName; + len = wcslen(data.cFileName) * sizeof(WCHAR); /* * Append name after slash, and recurse on the file. @@ -1387,7 +1384,7 @@ TraverseWinTree( if (nativeErrfile != NULL) { TclWinConvertError(GetLastError()); if (errorPtr != NULL) { - tclWinProcs->tchar2utf(nativeErrfile, -1, errorPtr); + Tcl_WinTCharToUtf(nativeErrfile, -1, errorPtr); } result = TCL_ERROR; } @@ -1433,9 +1430,9 @@ TraversalCopy( break; case DOTREE_PRED: if (DoCreateDirectory(nativeDst) == TCL_OK) { - DWORD attr = tclWinProcs->getFileAttributesProc(nativeSrc); + DWORD attr = GetFileAttributes(nativeSrc); - if (tclWinProcs->setFileAttributesProc(nativeDst, + if (SetFileAttributes(nativeDst, attr) != FALSE) { return TCL_OK; } @@ -1452,7 +1449,7 @@ TraversalCopy( */ if (errorPtr != NULL) { - tclWinProcs->tchar2utf(nativeDst, -1, errorPtr); + Tcl_WinTCharToUtf(nativeDst, -1, errorPtr); } return TCL_ERROR; } @@ -1507,7 +1504,7 @@ TraversalDelete( } if (errorPtr != NULL) { - tclWinProcs->tchar2utf(nativeSrc, -1, errorPtr); + Tcl_WinTCharToUtf(nativeSrc, -1, errorPtr); } return TCL_ERROR; } @@ -1571,7 +1568,7 @@ GetWinFileAttributes( int attr; nativeName = Tcl_FSGetNativePath(fileName); - result = tclWinProcs->getFileAttributesProc(nativeName); + result = GetFileAttributes(nativeName); if (result == 0xffffffff) { StatError(interp, fileName); @@ -1701,7 +1698,7 @@ ConvertFileNameFormat( const TCHAR *nativeName; const char *tempString; int tempLen; - WIN32_FIND_DATAT data; + WIN32_FIND_DATA data; HANDLE handle; DWORD attr; @@ -1715,9 +1712,9 @@ ConvertFileNameFormat( Tcl_DStringInit(&ds); tempString = Tcl_GetStringFromObj(tempPath,&tempLen); - nativeName = tclWinProcs->utf2tchar(tempString, tempLen, &ds); + nativeName = Tcl_WinUtfToTChar(tempString, tempLen, &ds); Tcl_DecrRefCount(tempPath); - handle = tclWinProcs->findFirstFileProc(nativeName, &data); + handle = FindFirstFile(nativeName, &data); if (handle == INVALID_HANDLE_VALUE) { /* * FindFirstFile() doesn't like root directories. We would @@ -1726,7 +1723,7 @@ ConvertFileNameFormat( * root directory */ - attr = tclWinProcs->getFileAttributesProc(nativeName); + attr = GetFileAttributes(nativeName); if ((attr!=0xFFFFFFFF) && (attr & FILE_ATTRIBUTE_DIRECTORY)) { Tcl_DStringFree(&ds); goto simple; @@ -1740,14 +1737,14 @@ ConvertFileNameFormat( } goto cleanup; } - nativeName = (TCHAR *) data.w.cAlternateFileName; + nativeName = data.cAlternateFileName; if (longShort) { - if (data.w.cFileName[0] != '\0') { - nativeName = (TCHAR *) data.w.cFileName; + if (data.cFileName[0] != TEXT('\0')) { + nativeName = data.cFileName; } } else { - if (data.w.cAlternateFileName[0] == '\0') { - nativeName = (TCHAR *) data.w.cFileName; + if (data.cAlternateFileName[0] == TEXT('\0')) { + nativeName = (TCHAR *) data.cFileName; } } @@ -1764,7 +1761,7 @@ ConvertFileNameFormat( */ Tcl_DStringInit(&dsTemp); - tclWinProcs->tchar2utf(nativeName, -1, &dsTemp); + Tcl_WinTCharToUtf(nativeName, -1, &dsTemp); /* * Deal with issues of tildes being absolute. @@ -1897,7 +1894,7 @@ SetWinFileAttributes( const TCHAR *nativeName; nativeName = Tcl_FSGetNativePath(fileName); - fileAttributes = tclWinProcs->getFileAttributesProc(nativeName); + fileAttributes = GetFileAttributes(nativeName); if (fileAttributes == 0xffffffff) { StatError(interp, fileName); @@ -1915,7 +1912,7 @@ SetWinFileAttributes( fileAttributes &= ~(attributeArray[objIndex]); } - if (!tclWinProcs->setFileAttributesProc(nativeName, fileAttributes)) { + if (!SetFileAttributes(nativeName, fileAttributes)) { StatError(interp, fileName); return TCL_ERROR; } |