Changeset 9959 for trunk/src


Ignore:
Timestamp:
Mar 31, 2003, 12:27:55 PM (22 years ago)
Author:
sandervl
Message:

DT: Shell file operations update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/shlfileop.c

    r9833 r9959  
    492492}
    493493
     494/**************************************************************************
     495 *      SHELL_FileNamesMatch()
     496 *
     497 * Accepts two \0 delimited lists of the file names. Checks whether number of
     498 * files in the both lists is the same,
     499 * and checks also if source-name exists.
     500 */
     501BOOL SHELL_FileNamesMatch(LPCWSTR pszFiles1, LPCWSTR pszFiles2, BOOL B_OnlyFrom)
     502{
     503        while (              (pszFiles1[0] != '\0') &&
     504             (B_OnlyFrom || (pszFiles2[0] != '\0')))
     505        {
     506          if (NULL == StrPBrkW(pszFiles1, wWildcardChars))
     507          {
     508            if (-1 == GetFileAttributesW(pszFiles1))
     509              return FALSE;
     510          }
     511          pszFiles1 += lstrlenW(pszFiles1) + 1;
     512          if (!B_OnlyFrom)
     513            pszFiles2 += lstrlenW(pszFiles2) + 1;
     514        }
     515        return
     516          (              (pszFiles1[0] == '\0') &&
     517          (B_OnlyFrom || (pszFiles2[0] == '\0')));
     518}
     519
    494520/*************************************************************************
    495521 *
     
    546572            {
    547573              retCode = ERROR_OUTOFMEMORY;
     574              SetLastError(retCode);
    548575              goto shfileop_error;
    549576            }
     
    564591        {
    565592          nFileOp.fAnyOperationsAborted = TRUE;
    566           SetLastError(retCode);
    567593        }
    568594        lpFileOp->hNameMappings = nFileOp.hNameMappings;
     
    577603 *     exported by name
    578604 */
     605
     606/* in w98 brings shell32_test.exe this 4 failures
     607shlfileop.c:177: Test failed: Can't rename many files
     608 * W98 return 0 without action
     609shlfileop.c:185: Test failed: Can't rename many files
     610 * W98 return 0 without action
     611shlfileop.c:286: Test failed: Files are copied to other directory
     612shlfileop.c:287: Test failed: The file is copied
     613 * This two messages are in W98 / W2K also
     614shlfileop: 121 tests executed, 0 marked as todo, 4 failures.
     615 * this implementation has only the last 2 messages (W2K lyke)
     616*/
     617
    579618DWORD WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
    580619{
     
    585624        LPCWSTR pFrom = pNextFrom;
    586625        LPCWSTR pTo = NULL;
     626        LPCSTR Debug_pFrom;
     627        LPCSTR Debug_pTo;
    587628        HANDLE hFind = INVALID_HANDLE_VALUE;
    588629        WIN32_FIND_DATAW wfd;
     
    595636        DWORD ToAttr;
    596637        DWORD ToPathAttr;
     638        DWORD FromPathAttr;
    597639        FILEOP_FLAGS OFl = ((FILEOP_FLAGS)lpFileOp->fFlags & 0x7ff);
    598640
     
    600642
    601643        BOOL b_MultiTo = (FO_DELETE != (lpFileOp->wFunc & 0xf));
     644        BOOL b_MultiPaired = (!b_MultiTo);
    602645        BOOL b_MultiFrom = FALSE;
    603646        BOOL not_overwrite;
     
    665708/*    OFl ^= (FOF_SILENT | FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOCONFIRMMKDIR); */
    666709          OFl &= (~(FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | FOF_FILESONLY));  /* implemented */
    667           OFl ^= (FOF_SILENT | FOF_NOCONFIRMMKDIR);          /* ignored, if one */
     710          OFl ^= (FOF_SILENT | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI); /* ignored, if one */
    668711          OFl &= (~FOF_SIMPLEPROGRESS);                      /* ignored, only with FOF_SILENT */
    669712          if (OFl)
    670713          {
    671             if (OFl & ( ~ (FOF_CONFIRMMOUSE | FOF_SILENT | FOF_RENAMEONCOLLISION | FOF_NOCONFIRMMKDIR)))
     714            if (OFl & ( ~ (FOF_CONFIRMMOUSE | FOF_SILENT | FOF_RENAMEONCOLLISION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI)))
    672715            {
    673716              TRACE("%s level=%d lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n", cFO_Name[0], level, OFl);
     
    684727          {
    685728            nFileOp.pFrom = pTempFrom = HeapAlloc(GetProcessHeap(), 0, ((1 + 2 * (b_MultiTo)) * MAX_PATH + 6) * sizeof(WCHAR));
     729            if (!pTempFrom)
     730            {
     731              retCode = ERROR_OUTOFMEMORY;
     732              SetLastError(retCode);
     733              goto shfileop_error;
     734            }
    686735            if (b_MultiTo)
    687736              pTempTo = &pTempFrom[MAX_PATH + 4];
     
    715764            pFromFile = SHFileStrCpyCatW(pTempFrom, pFrom, NULL);
    716765
     766/* for seeing in debugger outside from TRACE */
     767            Debug_pFrom = debugstr_w(pFrom);
     768            Debug_pTo = debugstr_w(pTo);
     769            TRACE("%s level=%d with %s %s%s\n",
     770              cFO_Name[0], level, Debug_pFrom, pTo ? "-> ":"", Debug_pTo);
     771
    717772            if (pTo)
    718773            {
    719774              pToFile = SHFileStrCpyCatW(pTempTo, pTo, NULL);
    720775            }
    721             if (!(pFromFile) || !(pFromFile[1]) || ((pTo) && !(pToFile)))
     776            if (!b_MultiPaired)
     777            {
     778              b_MultiPaired =
     779                SHELL_FileNamesMatch(lpFileOp->pFrom, lpFileOp->pTo, (!b_Multi || b_MultiFrom));
     780            } /* endif */
     781            if (!(b_MultiPaired) || !(pFromFile) || !(pFromFile[1]) || ((pTo) && !(pToFile)))
    722782            {
    723783              retCode = 0x402;      /* 1026 */
     
    748808                /* no work, only RC=0 */
    749809/* ???    nFileOp.fAnyOperationsAborted = TRUE; */
     810//#define W98_FO_RENEME
     811#ifdef W98_FO_RENEME
    750812                goto shfileop_normal;
     813#endif
     814                retCode = 0x1;      /* 1 value unknown, W98 returns no error */
     815                goto shfileop_error;
    751816              }
    752817            }
     
    755820            if (INVALID_HANDLE_VALUE == hFind)
    756821            {
     822               if ((FO_DELETE == FuncSwitch) && (b_Mask))
     823              {
     824                pFromFile[0] = '\0';
     825                FromPathAttr = GetFileAttributesW(pTempFrom);
     826                pFromFile[0] = '\\';
     827                if (IsAttribDir(FromPathAttr))
     828                {
     829                /* FO_DELETE with mask and without found is valid */
     830                  goto shfileop_normal;
     831                 } /* endif */
     832               } /* endif */
    757833              /* root (without mask) is also not allowed as source, tested in W98 */
    758834              retCode = 0x402;   /* 1026 */
     
    772848                 if (!lpFileName[0])
    773849                   lpFileName = wfd.cFileName;
    774                 if (IsDotDir(lpFileName))
    775                   continue;
     850                if (IsDotDir(lpFileName) ||
     851                    ((b_Mask) && IsAttribDir(wfd.dwFileAttributes) && (nFileOp.fFlags & FOF_FILESONLY)))
     852                  continue; /* next name in pTempFrom(dir) */
    776853                SHFileStrCpyCatW(&pFromFile[1], lpFileName, NULL);
    777854                /* TODO: Check the SHELL_DeleteFileOrDirectoryW() function in shell32.dll */
     
    10261103        {
    10271104          nFileOp.fAnyOperationsAborted = TRUE;
    1028           SetLastError(retCode);
    1029         }
    1030         TRACE("%s level=%d AnyOpsAborted=%s ret=0x%x, with %s%s%s\n",
     1105        }
     1106        TRACE("%s level=%d AnyOpsAborted=%s ret=0x%x, with %s %s%s\n",
    10311107              cFO_Name[0], level, nFileOp.fAnyOperationsAborted ? "TRUE":"FALSE",
    1032               retCode, debugstr_w(pFrom), pTo ? " -> ":"", debugstr_w(pTo));
     1108              retCode, debugstr_w(pFrom), pTo ? "-> ":"", debugstr_w(pTo));
    10331109
    10341110        lpFileOp->fAnyOperationsAborted = nFileOp.fAnyOperationsAborted;
     
    10791155
    10801156
     1157
Note: See TracChangeset for help on using the changeset viewer.