Author: tfaber Date: Fri Aug 28 11:39:45 2015 New Revision: 68847
URL: http://svn.reactos.org/svn/reactos?rev=68847&view=rev Log: [CMD] - Avoid statically importing FindFirstStreamW/FindNextStreamW so that our cmd.exe can work on WinXP. - Accept lowercase /r switch
Modified: trunk/reactos/base/shell/cmd/dir.c
Modified: trunk/reactos/base/shell/cmd/dir.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/dir.c?rev=68... ============================================================================== --- trunk/reactos/base/shell/cmd/dir.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/dir.c [iso-8859-1] Fri Aug 28 11:39:45 2015 @@ -341,7 +341,7 @@ lpFlags->bRecursive = ! bNegative; else if (cCurUChar == _T('X')) lpFlags->bShortName = ! bNegative; - else if (cCurChar == _T('R')) + else if (cCurUChar == _T('R')) lpFlags->bDataStreams = ! bNegative; else if (cCurChar == _T('4')) lpFlags->b4Digit = ! bNegative; @@ -1342,6 +1342,8 @@ WIN32_FIND_STREAM_DATA wfsdStreamInfo; PDIRFINDSTREAMNODE * ptrCurNode; /* The pointer to the first stream */ PDIRFINDSTREAMNODE ptrFreeNode; /* The pointer used during cleanup */ + static HANDLE (WINAPI *pFindFirstStreamW)(LPCWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD); + static BOOL (WINAPI *pFindNextStreamW)(HANDLE, LPVOID);
/* Initialize Variables */ ptrStartNode = NULL; @@ -1437,13 +1439,28 @@ /* Alternate streams are only displayed with new long list */ if (lpFlags->bNewLongList && lpFlags->bDataStreams) { + if (!pFindFirstStreamW) + { + pFindFirstStreamW = (PVOID)GetProcAddress(GetModuleHandle(_T("kernel32")), "FindFirstStreamW"); + pFindNextStreamW = (PVOID)GetProcAddress(GetModuleHandle(_T("kernel32")), "FindNextStreamW"); + } + /* Try to get stream information */ - hStreams = FindFirstStreamW(wfdFileInfo.cFileName, FindStreamInfoStandard, &wfsdStreamInfo, 0); + if (pFindFirstStreamW && pFindNextStreamW) + { + hStreams = pFindFirstStreamW(wfdFileInfo.cFileName, FindStreamInfoStandard, &wfsdStreamInfo, 0); + } + else + { + hStreams = INVALID_HANDLE_VALUE; + ERR("FindFirstStreamW not supported!\n"); + } + if (hStreams != INVALID_HANDLE_VALUE) { /* We totally ignore first stream. It contains data about ::$DATA */ ptrCurNode = &ptrNextNode->ptrNext->stInfo.ptrHead; - while (FindNextStreamW(hStreams, &wfsdStreamInfo)) + while (pFindNextStreamW(hStreams, &wfsdStreamInfo)) { *ptrCurNode = cmd_alloc(sizeof(DIRFINDSTREAMNODE)); if (*ptrCurNode == NULL)