Changeset 9808 for trunk/src


Ignore:
Timestamp:
Feb 15, 2003, 1:20:11 PM (23 years ago)
Author:
sandervl
Message:

DT: updates

Location:
trunk/src/shell32
Files:
1 added
1 edited

Legend:

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

    r9805 r9808  
     1
    12/*
    23 * SHFileOperation
     
    4142BOOL SHELL_ConfirmDialog (int nKindOfDialog, LPCSTR szDir)
    4243{
    43   char szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
    44         UINT caption_resource_id, text_resource_id;
     44        char szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
     45        UINT caption_resource_id, text_resource_id;
    4546
    4647  switch(nKindOfDialog) {
     
    8182 * like rm -r
    8283 */
     84
    8385BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI)
    8486{
    85   BOOL    ret = FALSE;
    86   HANDLE    hFind;
     87  BOOL    ret = TRUE;
     88  HANDLE  hFind;
    8789  WIN32_FIND_DATAA wfd;
    88   char    szTemp[MAX_PATH];
    89 
    90   strcpy(szTemp, pszDir);
    91   PathAddBackslashA(szTemp);
    92   strcat(szTemp, "*.*");
    93 
     90        char            szTemp[MAX_PATH];
     91
     92        /* Make sure the directory exists before eventually prompting the user */
     93        PathCombineA(szTemp, pszDir, "*.*");
    9494  hFind = FindFirstFileA(szTemp, &wfd);
    95 
    96   ret = (INVALID_HANDLE_VALUE != hFind);
    97 
    98   if (ret && (!bShowUI || SHELL_ConfirmDialog(ASK_DELETE_FOLDER, pszDir)))
    99   {
    100     do
    101     {
    102       if(strcasecmp(wfd.cFileName, ".") && strcasecmp(wfd.cFileName, ".."))
    103       {
    104         strcpy(szTemp, pszDir);
    105         PathAddBackslashA(szTemp);
    106         strcat(szTemp, wfd.cFileName);
    107 
    108         if(FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
    109           SHELL_DeleteDirectoryA(szTemp, FALSE);
    110         else
    111           DeleteFileA(szTemp);
    112       }
    113     } while(FindNextFileA(hFind, &wfd));
    114     FindClose(hFind);
    115     ret = RemoveDirectoryA(pszDir);
    116   }
    117   return ret;
     95        if (hFind == INVALID_HANDLE_VALUE)
     96          return FALSE;
     97
     98        if (!bShowUI || SHELL_ConfirmDialog(ASK_DELETE_FOLDER, pszDir))
     99        {
     100          do
     101          {
     102            if (lstrcmpA(wfd.cFileName, ".") && lstrcmpA(wfd.cFileName, ".."))
     103      {
     104              PathCombineA(szTemp, pszDir, wfd.cFileName);
     105              if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
     106                ret = SHELL_DeleteDirectoryA(szTemp, FALSE);
     107              else
     108                ret = DeleteFileA(szTemp);
     109            }
     110          } while (ret && FindNextFileA(hFind, &wfd));
     111        }
     112        FindClose(hFind);
     113        if (ret)
     114          ret = RemoveDirectoryA(pszDir);
     115        return ret;
    118116}
    119117
     
    124122BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI)
    125123{
    126   if (bShowUI && !SHELL_ConfirmDialog(ASK_DELETE_FILE, pszFile))
    127     return FALSE;
    128         return DeleteFileA(pszFile);
     124        if (bShowUI && !SHELL_ConfirmDialog(ASK_DELETE_FILE, pszFile))
     125          return FALSE;
     126
     127        return DeleteFileA(pszFile);
     128}
     129
     130/**************************************************************************
     131 * Win32CreateDirectory      (SHELL32_93)   [SHELL32.93]
     132 *
     133 * Creates a directory. Also triggers a change notify if one exists.
     134 */
     135static BOOL Win32CreateDirectoryA(LPCSTR path, LPSECURITY_ATTRIBUTES sec)
     136{
     137        BOOL ret;
     138        TRACE("(%%s, %p)\n", debugstr_a(path), sec);
     139
     140        ret = CreateDirectoryA(path, sec);
     141        if (ret)
     142        {
     143          SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHA, path, NULL);
     144        }
     145        return ret;
     146}
     147
     148static BOOL Win32CreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
     149{
     150        BOOL ret;
     151        TRACE("(%%s, %p)\n", debugstr_w(path), sec);
     152
     153        ret = CreateDirectoryW(path, sec);
     154        if (ret)
     155        {
     156          SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW, path, NULL);
     157        }
     158        return ret;
     159}
     160
     161BOOL WINAPI Win32CreateirectoryAW(LPCVOID path, LPSECURITY_ATTRIBUTES sec)
     162{
     163        if (SHELL_OsIsUnicode())
     164          return Win32CreateDirectoryW(path, sec);
     165        return Win32CreateDirectoryA(path, sec);
     166}
     167
     168/************************************************************************
     169 * Win32RemoveDirectory      (SHELL32_94)   [SHELL32.94]
     170 *
     171 * Deletes a directory. Also triggers a change notify if one exists.
     172 */
     173static BOOL Win32RemoveDirectoryA(LPCSTR path)
     174{
     175        DWORD attr;
     176        BOOL ret;
     177        TRACE("(%%s)\n", debugstr_a(path));
     178       
     179        ret = RemoveDirectoryA(path);
     180        if (!ret)
     181        {
     182          attr = GetFileAttributesA(path);
     183          if (attr != -1 && attr & FILE_ATTRIBUTE_READONLY)
     184          {
     185            SetFileAttributesA(path, attr & ~FILE_ATTRIBUTE_READONLY);
     186            ret = RemoveDirectoryA(path);
     187          }
     188        }
     189        if (ret)
     190        {
     191          SHChangeNotify(SHCNE_RMDIR, SHCNF_PATHA, path, NULL);
     192        }
     193        return ret;
     194}
     195
     196static BOOL Win32RemoveDirectoryW(LPCWSTR path)
     197{
     198        DWORD attr;
     199        BOOL ret;
     200        TRACE("(%%s)\n", debugstr_w(path));
     201       
     202        ret = RemoveDirectoryW(path);
     203        if (!ret)
     204        {
     205          attr = GetFileAttributesW(path);
     206          if (attr != -1 && attr & FILE_ATTRIBUTE_READONLY)
     207          {
     208            SetFileAttributesW(path, attr & ~FILE_ATTRIBUTE_READONLY);
     209            ret = RemoveDirectoryW(path);
     210          }
     211        }
     212        if (ret)
     213        {
     214          SHChangeNotify(SHCNE_RMDIR, SHCNF_PATHW, path, NULL);
     215        }
     216        return ret;
     217}
     218
     219BOOL WINAPI Win32RemoveDirectoryAW(LPCVOID path)
     220{
     221        if (SHELL_OsIsUnicode())
     222          return Win32RemoveDirectoryW(path);
     223        return Win32RemoveDirectoryA(path);
     224}
     225
     226/************************************************************************
     227 * Win32DeleteFile           (SHELL32_164)  [SHELL32.164]
     228 *
     229 * Deletes a file. Also triggers a change notify if one exists.
     230 *
     231 * NOTES:
     232 *  Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be ANSI.
     233 *  This is Unicode on NT/2000
     234 */
     235static BOOL Win32DeleteFileA(LPCSTR path)
     236{
     237        BOOL ret;
     238
     239        TRACE("(%s)\n", debugstr_a(path));
     240
     241        ret = DeleteFileA(path);
     242        if (!ret)
     243        {
     244          /* File may be write protected or a system file */
     245          DWORD dwAttr = GetFileAttributesA(path);
     246          if ((dwAttr != -1) && (dwAttr & FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
     247            if (SetFileAttributesA(path, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
     248              ret = DeleteFileA(path);
     249        }
     250        if (ret)
     251          SHChangeNotify(SHCNE_DELETE, SHCNF_PATHA, path, NULL);
     252        return ret;
     253}
     254
     255static BOOL Win32DeleteFileW(LPCWSTR path)
     256{
     257        BOOL ret;
     258       
     259        TRACE("(%s)\n", debugstr_w(path));
     260
     261        ret = DeleteFileW(path);
     262        if (!ret)
     263        {
     264          /* File may be write protected or a system file */
     265          DWORD dwAttr = GetFileAttributesW(path);
     266          if ((dwAttr != -1) && (dwAttr & FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
     267            if (SetFileAttributesW(path, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
     268              ret = DeleteFileW(path);
     269        }
     270        if (ret)
     271          SHChangeNotify(SHCNE_DELETE, SHCNF_PATHW, path, NULL);
     272        return ret;
     273}
     274
     275DWORD WINAPI Win32DeleteFileAW(LPCVOID path)
     276{
     277        if (SHELL_OsIsUnicode())
     278          return Win32DeleteFileW(path);
     279        return Win32DeleteFileA(path);
    129280}
    130281
     
    148299DWORD WINAPI SHCreateDirectoryExA(HWND hWnd, LPCSTR path, LPSECURITY_ATTRIBUTES sec)
    149300{
    150         DWORD ret;
    151         TRACE("(%p, %s, %p)\n",hWnd, path, sec);
    152     ret = CreateDirectoryA(path, sec);
    153         if (ret)
    154         {
    155           SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHA, path, NULL);
    156         }
    157         else if (hWnd)
    158           FIXME("Semi-stub, non zero hWnd should be used as parent for error dialog!");
     301        WCHAR wPath[MAX_PATH];
     302        TRACE("(%p, %s, %p)\n",hWnd, debugstr_a(path), sec);
     303
     304        MultiByteToWideChar(CP_ACP, 0, path, -1, wPath, MAX_PATH);
     305        return SHCreateDirectoryExW(hWnd, wPath, sec);
     306}
     307
     308/*************************************************************************
     309 * SHCreateDirectoryExW                     [SHELL32.@]
     310 */
     311DWORD WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
     312{
     313        DWORD ret = ERROR_SUCCESS;
     314        TRACE("(%p, %s, %p)\n",hWnd, debugstr_w(path), sec);
     315
     316        if (PathIsRelativeW(path))
     317        {
     318          ret = ERROR_BAD_PATHNAME;
     319          SetLastError(ERROR_BAD_PATHNAME);
     320        }
     321        else
     322        {
     323          if (!Win32CreateDirectoryW(path, sec))
     324          {
     325            ret = GetLastError();
     326            if (ret != ERROR_FILE_EXISTS &&
     327                ret != ERROR_ALREADY_EXISTS &&
     328                ret != ERROR_FILENAME_EXCED_RANGE)
     329            {
     330            /*lstrcpynW(pathName, path, MAX_PATH);
     331              lpStr = PathAddBackslashW(pathName);*/
     332              FIXME("Semi-stub, non zero hWnd should be used somehow?");
     333            }
     334          }
     335        }
    159336        return ret;
    160337}
    161338
    162339/*************************************************************************
    163  * SHCreateDirectoryExW                     [SHELL32.@]
    164  */
    165 DWORD WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
    166 {
    167         DWORD ret;
    168         TRACE("(%p, %s, %p)\n",hWnd, debugstr_w(path), sec);
    169         ret = CreateDirectoryW(path, sec);
    170         if (ret)
    171         {
    172           SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW, path, NULL);
    173         }
    174         else if (hWnd)
    175           FIXME("Semi-stub, non zero hWnd should be used as parent for error dialog!");
    176         return ret;
    177 }
    178 
    179 /************************************************************************
    180  * Win32DeleteFile                         [SHELL32.164]
    181  *
    182  * Deletes a file. Also triggers a change notify if one exists.
    183  *
    184  * NOTES:
    185  *  Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be ANSI.
    186  *  This is Unicode on NT/2000
    187  */
    188 static BOOL Win32DeleteFileA(LPCSTR fName)
    189 {
    190         DWORD ret;
    191         TRACE("%p(%s)\n", fName, fName);
    192 
    193         if (!(ret = DeleteFileA(fName)))
    194         {
    195           /* File may be write protected or a system file */
    196           DWORD dwAttr = GetFileAttributesA(fName);
    197           if ((dwAttr != -1) && (dwAttr & FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
    198             if (SetFileAttributesA(fName, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
    199                   ret = DeleteFileA(fName);
    200         }
    201         if (ret)
    202           SHChangeNotify(SHCNE_DELETE, SHCNF_PATHA, fName, NULL);
    203         return ret;
    204 }
    205 
    206 static BOOL Win32DeleteFileW(LPCWSTR fName)
    207 {
    208         BOOL ret;
    209         TRACE("%p(%s)\n", fName, debugstr_w(fName));
    210 
    211         if (!(ret = DeleteFileW(fName)))
    212         {
    213           /* File may be write protected or a system file */
    214           DWORD dwAttr = GetFileAttributesW(fName);
    215           if ((dwAttr != -1) && (dwAttr & FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM))
    216             if (SetFileAttributesW(fName, dwAttr & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM)))
    217                   ret = DeleteFileW(fName);
    218         }
    219         if (ret)
    220           SHChangeNotify(SHCNE_DELETE, SHCNF_PATHW, fName, NULL);
    221         return ret;
    222 }
    223 
    224 BOOL WINAPI Win32DeleteFileAW(LPCVOID fName)
    225 {
    226         if (SHELL_OsIsUnicode())
    227           return Win32DeleteFileW(fName);
    228         return Win32DeleteFileA(fName);
    229 }
    230 
    231 /*************************************************************************
    232  *
    233  * SHFileStrCpyCat HelperFunction for SHFileOperationA
    234  *
    235  */
    236 LPSTR SHFileStrCpyCatA(LPSTR pTo, LPCSTR pFrom, LPCSTR pCatStr)
    237 {
    238   LPSTR pToFile = NULL;
    239   int  i_len;
    240 
    241   if (pTo)
    242         {
    243           if (pFrom)
    244             lstrcpyA(pTo, pFrom);
    245           if (pCatStr) /* lstrcatA(pTo, pCatStr); ?? */
    246           {
    247             i_len = lstrlenA(pTo);
    248             if ((i_len) && (pCatStr[0] == '\\') && (pTo[--i_len] == '\\'))
    249               pTo[i_len] = '\0';
    250             lstrcatA(pTo, pCatStr);
    251     }
    252     pToFile = strrchr(pTo,'\\');
    253 /* !! termination of the new string-group */
    254           pTo[(lstrlenA(pTo)) + 1] = '\0';
    255   }
    256   return pToFile;
    257 }
    258 
    259 /*************************************************************************
    260340 *
    261341 * SHFileStrICmp HelperFunction for SHFileOperationA
     
    265345{
    266346  CHAR C1 = '\0';
    267   CHAR C2  = '\0';
     347  CHAR C2 = '\0';
    268348  int i_Temp = -1;
    269         int i_len1 = lstrlenA(p1);
    270         int i_len2 = lstrlenA(p2);
     349  int i_len1 = lstrlenA(p1);
     350  int i_len2 = lstrlenA(p2);
    271351
    272352  if (p1End && (&p1[i_len1] >= p1End) && ('\\' == p1End[0]))
     
    274354     C1 = p1End[0];
    275355    p1End[0] = '\0';
    276           i_len1 = lstrlenA(p1);
     356    i_len1 = lstrlenA(p1);
    277357  }
    278358  if (p2End)
     
    294374    }
    295375  }
    296         i_len2 = lstrlenA(p2);
    297         if (i_len1 == i_len2)
    298           i_Temp = lstrcmpiA(p1,p2);
     376  i_len2 = lstrlenA(p2);
     377  if (i_len1 == i_len2)
     378    i_Temp = lstrcmpiA(p1,p2);
    299379  if (C1)
    300380    p1[i_len1] = C1;
     
    303383  return !(i_Temp);
    304384}
    305 
    306 #define IsAttribFile(x) (!(x == -1) && !(x & FILE_ATTRIBUTE_DIRECTORY))
    307 #define IsAttribDir(x)  (!(x == -1) && (x & FILE_ATTRIBUTE_DIRECTORY))
    308 #define TextFromPtr(x) (x ? x:"NULL")
     385/*************************************************************************
     386 *
     387 * SHFileStrCpyCat HelperFunction for SHFileOperationA/W
     388 *
     389 */
     390#define I_SHFileStrCpyCatA
     391#include "shlfileop.h"
     392#define I_SHFileStrCpyCatW
     393#include "shlfileop.h"
     394
    309395/*************************************************************************
    310396 * SHFileOperationA        [SHELL32.@]
     
    344430  BOOL b_Mask; /* wird als Schalter benutzt, vieleicht finde ich die richtige bitposition */
    345431  BOOL b_ToTailSlash;
    346   LPSTR pToFuncTXT;
     432
     433  LPCSTR cFO_Name [4] = { "FO_MOVE", "FO_COPY", "FO_DELETE", "FO_RENAME" };
     434  LPCSTR pToFuncTXT = "FO_????";
    347435
    348436  long FuncSwitch = (nlpFileOp.wFunc & 0xf);
     
    352440  nlpFileOp.fAnyOperationsAborted=FALSE;
    353441
    354   switch(FuncSwitch)
    355   {
    356   case FO_MOVE:
    357     pToFuncTXT = "FO_MOVE";break;
    358   case FO_COPY:
    359     pToFuncTXT = "FO_COPY";break;
    360   case FO_DELETE:
    361     pToFuncTXT = "FO_DELETE";break;
    362   case FO_RENAME:
    363     pToFuncTXT = "FO_RENAME";break;
    364   default:
    365     pToFuncTXT = "FO_????";
     442  if (!(FuncSwitch) || (FO_RENAME < FuncSwitch))
    366443    goto shfileop_normal;
    367   }
    368 
     444
     445  pToFuncTXT = cFO_Name [FuncSwitch-1];
    369446  if (level == 0)
    370447    TRACE("%s: flags (0x%04x) : %s%s%s%s%s%s%s%s%s%s%s%s \n",pToFuncTXT, nlpFileOp.fFlags,
     
    399476                 * create dir              0 0 0 0 0 0 1 0
    400477                 */
    401 /* 
     478/*
    402479 * FOF_MULTIDESTFILES, FOF_NOCONFIRMATION, FOF_FILESONLY          are    implemented
    403480 * FOF_CONFIRMMOUSE, FOF_SILENT, FOF_NOCONFIRMMKDIR, FOF_SIMPLEPROGRESS    are not implemented and ignored
     
    405482 * FOF_ALLOWUNDO, FOF_WANTMAPPINGHANDLE                    are not implemented and breaks
    406483 * if any other flag set, an error occurs
    407  */ 
     484 */
    408485    TRACE(__FUNCTION__" %s level=%d nlpFileOp.fFlags=0x%x\n", pToFuncTXT, level, lpFileOp->fFlags);
    409486
     
    418495      {
    419496        TRACE("%s level=%d lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n", pToFuncTXT, level, OFl);
    420         retCode = 0x403; /* we need a extension of shlfileop */
    421         nlpFileOp.fAnyOperationsAborted=TRUE;
     497        retCode = 0x403; /* 1027, we need a extension of shlfileop */
     498        goto shfileop_error;
    422499      }
    423500      else
     
    437514    else
    438515    {
    439       nlpFileOp.fAnyOperationsAborted=TRUE;
    440       retCode = 0x402;
     516      retCode = 0x402;      /* 1026 */
    441517      goto shfileop_error;
    442518    }
     
    450526      {
    451527        pTo = pNextTo;
    452             pNextTo = &pNextTo[lstrlenA(pTo)+1];
     528        pNextTo = &pNextTo[lstrlenA(pTo)+1];
    453529        b_MultiTo = (b_Multi && pNextTo[0]);
    454530      }
    455531
    456532      pFrom = pNextFrom;
    457           pNextFrom = &pNextFrom[lstrlenA(pNextFrom)+1];
     533      pNextFrom = &pNextFrom[lstrlenA(pNextFrom)+1];
    458534      if (!b_MultiFrom && !b_MultiTo)
    459535        b_MultiFrom = (pNextFrom[0]);
    460536
    461           pFromFile = SHFileStrCpyCatA(pTempFrom, pFrom, NULL);
     537      pFromFile = SHFileStrCpyCatA(pTempFrom, pFrom, NULL);
    462538
    463539      if (pTo)
    464540      {
    465             pToFile = SHFileStrCpyCatA(pTempTo, pTo, NULL);
    466         if (!(pToFile))
    467         {
    468           nlpFileOp.fAnyOperationsAborted=TRUE;
    469           retCode = 0x402;
    470           goto shfileop_error;
    471         } /* endif */
     541        pToFile = SHFileStrCpyCatA(pTempTo, pTo, NULL);
     542      }
     543      if (!(pFromFile) || !(pFromFile[1]) || ((pTo) && !(pToFile)))
     544      {
     545         retCode = 0x402;      /* 1026 */
     546         goto shfileop_error;
     547      }
     548      if (pTo)
     549      {
    472550        b_ToTailSlash = (!pToFile[1]);
    473551        if (b_ToTailSlash)
     
    476554          if (strchr(pTempTo,'\\'))
    477555          {
    478                 pToFile = SHFileStrCpyCatA(pTempTo, NULL, NULL);
    479           }
    480         }
    481         b_ToInvalidTail = (NULL != strpbrk(&pToFile[1],"*?"));
    482       }
    483 
     556            pToFile = SHFileStrCpyCatA(pTempTo, NULL, NULL);
     557          }
     558        }
     559        b_ToInvalidTail = (NULL != StrPBrkA(&pToFile[1],"*?"));
     560      }
     561
     562      b_Mask = (NULL != StrPBrkA(&pFromFile[1],"*?"));
    484563      if (FO_RENAME == FuncSwitch)
    485564      {
    486 /* tempor„r only for FO_RENAME */
    487         b_Mask = (NULL != strpbrk(pFrom,"*?"));
    488         if (b_MultiTo || (pNextFrom[0]) || (b_Mask && !b_ToInvalidTail))
     565/* temporr only for FO_RENAME */
     566//        b_Mask = (NULL != strpbrk(pFrom,"*?"));
     567        if (b_MultiTo || b_MultiFrom || (b_Mask && !b_ToInvalidTail))
    489568        {
    490569/* no work, only RC=0 */
     
    493572        }
    494573      }
    495  
    496       hFind = (!(pFromFile) || !(pFromFile[1])) ? INVALID_HANDLE_VALUE : FindFirstFileA(pFrom, &wfd);
    497         if (INVALID_HANDLE_VALUE == hFind)
    498       {
    499 /* root (without mask) is also not allowed as source, tested in W98 */
    500         nlpFileOp.fAnyOperationsAborted=TRUE;
    501         retCode = 0x402;
     574
     575      hFind = FindFirstFileA(pFrom, &wfd);
     576      if (INVALID_HANDLE_VALUE == hFind)
     577      {
     578/* root (without mask) is also not allowed as source, tested in W98 */
     579        retCode = 0x402;   /* 1026 */
    502580        goto shfileop_error;
    503581      } /* endif */
     
    505583/* for all */
    506584#define HIGH_ADR (LPSTR)0xffffffff
    507           b_Mask = (!SHFileStrICmpA(&pFromFile[1], &wfd.cFileName[0], HIGH_ADR, HIGH_ADR));
     585//      b_Mask = (!SHFileStrICmpA(&pFromFile[1], &wfd.cFileName[0], HIGH_ADR, HIGH_ADR));
    508586
    509587      if (!pTo) /* FO_DELETE */
     
    513591          if (wfd.cFileName[0] == '.')
    514592          {
    515                 if (wfd.cFileName[1] == '\0')
    516                   continue;
    517                 if (wfd.cFileName[1] == '.' && wfd.cFileName[2] == '\0')
    518                   continue;
    519           }
    520               SHFileStrCpyCatA(&pFromFile[1], &wfd.cFileName[0], NULL);
     593          if (wfd.cFileName[1] == '\0')
     594            continue;
     595          if (wfd.cFileName[1] == '.' && wfd.cFileName[2] == '\0')
     596            continue;
     597          }
     598          SHFileStrCpyCatA(&pFromFile[1], wfd.cFileName, NULL);
    521599          if (IsAttribFile(wfd.dwFileAttributes))
    522600          {
    523                 nlpFileOp.fAnyOperationsAborted = (!Win32DeleteFileA(pTempFrom));
     601            nlpFileOp.fAnyOperationsAborted = (!Win32DeleteFileA(pTempFrom));
    524602            retCode = 0x78; /* value unknown */
    525603          }
    526604          else
    527605          {
    528             nlpFileOp.fAnyOperationsAborted = (!SHELL_DeleteDirectoryA(pTempFrom,FALSE));
    529             retCode = 0x78; /* value unknown */
     606            nlpFileOp.fAnyOperationsAborted = (!SHELL_DeleteDirectoryA(pTempFrom,(!(nlpFileOp.fFlags & FOF_NOCONFIRMATION))));
     607            retCode = 0x79; /* value unknown */
    530608          }
    531609        } while(!nlpFileOp.fAnyOperationsAborted && FindNextFileA(hFind, &wfd));
     
    540618
    541619      b_SameRoot = (toupper(pTempFrom[0]) == toupper(pTempTo[0]));
    542           b_SameTailName = SHFileStrICmpA(pToFile, pFromFile, NULL, NULL);
    543 
    544       /* W98 Bug with FO_MOVE(/RENAME ?) different to FO_COPY, better the same as FO_COPY */
    545 
    546           b_ToValid = ((b_SameTailName &&  b_SameRoot && (FO_COPY == FuncSwitch)) ||
    547                       (b_SameTailName && !b_SameRoot) || (b_ToInvalidTail));
     620      b_SameTailName = SHFileStrICmpA(pToFile, pFromFile, NULL, NULL);
    548621
    549622      ToPathAttr = ToAttr = GetFileAttributesA(pTempTo);
    550       if (!b_Mask && /* IsAttribDir(wfd.dwFileAttributes) && */(ToAttr -1))
     623      if (!b_Mask && (ToAttr -1))
    551624      {
    552625        if (pToFile)
     
    554627          pToFile[0] = '\0';
    555628          ToPathAttr = GetFileAttributesA(pTempTo);
    556           /* if (-1 != ToPathAttr) */  pToFile[0] = '\\';
    557         }
    558       }
     629          pToFile[0] = '\\';
     630        }
     631      }
     632
    559633      if (FO_RENAME == FuncSwitch)
    560634      {
    561635        if (!b_SameRoot || b_Mask /* FO_RENAME works not with Mask */
    562                || !SHFileStrICmpA(pTempFrom, pTempTo, pFromFile, NULL)
    563                || (SHFileStrICmpA(pTempFrom, pTempTo, pFromFile, HIGH_ADR) && !b_ToTailSlash))
     636         || !SHFileStrICmpA(pTempFrom, pTempTo, pFromFile, NULL)
     637         || (SHFileStrICmpA(pTempFrom, pTempTo, pFromFile, HIGH_ADR) && !b_ToTailSlash))
    564638        {
    565639          retCode = 0x73;
    566           nlpFileOp.fAnyOperationsAborted=TRUE;
    567640          goto shfileop_error;
    568641        }
    569642        if (b_ToInvalidTail)
    570643        {
    571           nlpFileOp.fAnyOperationsAborted=TRUE;
    572644          retCode=0x2;
    573645          goto shfileop_error;
    574646        }
     647        if (-1 == ToPathAttr)
     648        {
     649          retCode = 0x75;
     650          goto shfileop_error;
     651        }
    575652        if (IsAttribDir(wfd.dwFileAttributes) && IsAttribDir(ToAttr))
    576653        {
    577           if (b_ToTailSlash)
    578           {
    579             retCode = 0xb7;
    580           }
    581           else
    582           {
    583             retCode = 0x7b;
    584           }
    585           nlpFileOp.fAnyOperationsAborted=TRUE;
    586           goto shfileop_error;
    587         }
    588         if (-1 == ToPathAttr)
    589         {
    590           nlpFileOp.fAnyOperationsAborted=TRUE;
    591           retCode = 0x75;
     654          retCode = (b_ToTailSlash) ? 0xb7 : 0x7b;
    592655          goto shfileop_error;
    593656        } /* endif */
    594657        if (!MoveFileA(pTempFrom, pTempTo))
    595658        {
    596           nlpFileOp.fAnyOperationsAborted=TRUE;
    597659/* we need still the value for the returncode, we use the mostly assumed */
    598               retCode = 0xb7;
     660          retCode = 0xb7;
    599661          goto shfileop_error;
    600662        }
     
    602664      }
    603665
    604       if (!b_Mask && IsAttribDir(wfd.dwFileAttributes) && (ToAttr -1))
    605       {
    606         if (pToFile)
    607         {
    608           pToFile[0] = '\0';
    609           ToPathAttr = GetFileAttributesA(pTempTo);
    610           if ((ToPathAttr == -1) && b_ToValid)
    611           {
    612 /* create dir k”nnte hier erfolgen, smple target D:\y\ *.* create with RC=10003 */
    613             if(!SHCreateDirectory(NULL,pTempTo))
    614             {
    615               nlpFileOp.fAnyOperationsAborted=TRUE;
    616               retCode = 0x73;/* value unknown */
    617               goto shfileop_error;
    618             }
    619             ToPathAttr = GetFileAttributesA(pTempTo);
    620           }
    621           pToFile[0] = '\\';
    622           if (b_ToInvalidTail)
    623           {
    624             nlpFileOp.fAnyOperationsAborted=TRUE;
    625             retCode=0x10003;
    626             goto shfileop_error;
    627           }
    628         }
    629       }
     666      /* W98 Bug with FO_MOVE(/RENAME ?) different to FO_COPY, better the same as FO_COPY */
     667
     668      b_ToValid = ((b_SameTailName &&  b_SameRoot && (FO_COPY == FuncSwitch)) ||
     669                (b_SameTailName && !b_SameRoot) || (b_ToInvalidTail));
    630670
    631671/* handle mask in source */
     
    634674        if (!IsAttribDir(ToAttr))
    635675        {
    636           nlpFileOp.fAnyOperationsAborted=TRUE;
    637           if (b_ToInvalidTail && b_SameTailName && (FO_MOVE == FuncSwitch))
    638           {
    639             retCode = 0x2;
    640           }
    641           else
    642           {
    643             retCode = 0x75;
    644           }
     676          retCode = (b_ToInvalidTail &&/* b_SameTailName &&*/ (FO_MOVE == FuncSwitch)) \
     677            ? 0x2 : 0x75;
    645678          goto shfileop_error;
    646679        }
    647             pToFile = SHFileStrCpyCatA(pTempTo,NULL, "\\");
     680        pToFile = SHFileStrCpyCatA(pTempTo,NULL, "\\");
    648681        nlpFileOp.fFlags = (nlpFileOp.fFlags | FOF_MULTIDESTFILES);
    649682        do
     
    659692            continue; /* next name in pTempFrom(dir) */
    660693          }
    661               SHFileStrCpyCatA(&pToFile[1], &wfd.cFileName[0], NULL);
    662               SHFileStrCpyCatA(&pFromFile[1], &wfd.cFileName[0], NULL);
     694          SHFileStrCpyCatA(&pToFile[1], wfd.cFileName, NULL);
     695          SHFileStrCpyCatA(&pFromFile[1], wfd.cFileName, NULL);
    663696          retCode = SHFileOperationA (&nlpFileOp);
    664697        } while(!nlpFileOp.fAnyOperationsAborted && FindNextFileA(hFind, &wfd));
     
    670703        continue;
    671704
     705      if (IsAttribDir(wfd.dwFileAttributes) && (ToAttr -1))
     706      {
     707        if (pToFile)
     708        {
     709          pToFile[0] = '\0';
     710          ToPathAttr = GetFileAttributesA(pTempTo);
     711          if ((ToPathAttr == -1) && b_ToValid)
     712          {
     713/* create dir must be here, sample target D:\y\ *.* create with RC=10003 */
     714            if(SHCreateDirectoryExA(NULL,pTempTo, NULL))
     715            {
     716              retCode = 0x73;/* value unknown */
     717              goto shfileop_error;
     718            }
     719            ToPathAttr = GetFileAttributesA(pTempTo);
     720          }
     721          pToFile[0] = '\\';
     722          if (b_ToInvalidTail)
     723          {
     724            retCode=0x10003;
     725            goto shfileop_error;
     726          }
     727        }
     728      }
     729
    672730/* tailling BackSlash is ever removed and pToFile points to BackSlash before */
    673731      if (!b_MultiTo && (b_MultiFrom || (!(b_Multi) && IsAttribDir(ToAttr))))
     
    677735          if (b_Multi)
    678736          {
    679             retCode = 0x73; /* !b_Multi = 0x8 ?? */
    680             nlpFileOp.fAnyOperationsAborted=TRUE;
     737            retCode = 0x73; /* !b_Multi = 0x8 ?? */
    681738            goto shfileop_error;
    682739          }
    683740        }
    684             pToFile = SHFileStrCpyCatA(&pTempTo[strlen(pTempTo)], "\\", wfd.cFileName);
     741        pToFile = SHFileStrCpyCatA(pTempTo, NULL, wfd.cFileName);
    685742        ToAttr = GetFileAttributesA(pTempTo);
    686743      }
     
    690747        if (IsAttribFile(wfd.dwFileAttributes))
    691748        {
    692           if (FO_COPY == FuncSwitch)
    693           {
    694 /* ????? */ retCode = 0x75;
    695           }
    696           else
    697           {
    698             retCode = 0xb7;
    699           }
    700           nlpFileOp.fAnyOperationsAborted=TRUE;
     749          retCode = (FO_COPY == FuncSwitch) ? 0x75 : 0xb7;
    701750          goto shfileop_error;
    702751        }
     
    709758        if (IsAttribFile(ToPathAttr))
    710759        {
    711 /* fehler, ist das schon getestet ? */
    712           nlpFileOp.fAnyOperationsAborted=TRUE;
     760/* error, is this tested ? */
    713761          retCode = 0x777402;
    714762          goto shfileop_error;
     
    720768      {
    721769/* Target-dir does not exist, and can not created */
    722         nlpFileOp.fAnyOperationsAborted=TRUE;
    723770        retCode=0x75;
    724771        goto shfileop_error;
     
    728775      {
    729776      case FO_MOVE:
    730               if ((ToAttr == -1) && SHFileStrICmpA(pTempFrom, pTempTo, pFromFile, NULL))
    731         { 
     777        pToFile = NULL;
     778        if ((ToAttr == -1) && SHFileStrICmpA(pTempFrom, pTempTo, pFromFile, NULL))
     779        {
    732780          nlpFileOp.wFunc =  ((level+1)<<4) + FO_RENAME;
     781        }
     782        else
     783        {
     784          if (b_SameRoot && IsAttribDir(ToAttr) && IsAttribDir(wfd.dwFileAttributes))
     785          {
     786            pToFile = SHFileStrCpyCatA(pTempFrom, NULL, "*.*");
     787            retCode = SHFileOperationA(&nlpFileOp);
     788          }
     789          else
     790          {
     791            nlpFileOp.wFunc =  ((level+1)<<4) + FO_COPY;
     792          } /* endif */
     793        }
     794        retCode = SHFileOperationA(&nlpFileOp);
     795        if (pToFile)
     796          ((WORD*)pToFile)[0] = '\0';
     797        if (!nlpFileOp.fAnyOperationsAborted && (FO_RENAME != (nlpFileOp.wFunc & 0xf)))
     798        {
     799          nlpFileOp.wFunc =  ((level+1)<<4) + FO_DELETE;
    733800          retCode = SHFileOperationA(&nlpFileOp);
    734         }
    735         else
    736         {
    737           if (b_SameRoot && IsAttribDir(ToAttr) && IsAttribDir(wfd.dwFileAttributes))
    738           {
    739                   pToFile = SHFileStrCpyCatA(pTempFrom, NULL, "\\*.*");
    740                 retCode = SHFileOperationA(&nlpFileOp);
    741                   ((WORD*)pToFile)[0] = '\0';
    742           }
    743           else
    744           {
    745             nlpFileOp.wFunc =  ((level+1)<<4) + FO_COPY;
    746                 retCode = SHFileOperationA(&nlpFileOp);
    747           } /* endif */
    748           if (!nlpFileOp.fAnyOperationsAborted)
    749           {
    750             nlpFileOp.wFunc =  ((level+1)<<4) + FO_DELETE;
    751             retCode = SHFileOperationA(&nlpFileOp);
    752           } /* endif */
    753         }
     801        } /* endif */
    754802        continue;
    755803      case FO_COPY:
    756               if (SHFileStrICmpA(pTempFrom, pTempTo, NULL, NULL))
     804        if (SHFileStrICmpA(pTempFrom, pTempTo, NULL, NULL))
    757805        { /* target is the same as source ? */
    758           nlpFileOp.fAnyOperationsAborted=TRUE;
    759806/* we need still the value for the returncode, we assume 0x71 */
    760807          retCode = 0x71;
    761808          goto shfileop_error;
    762809        } /* endif */
    763               if (IsAttribDir((ToAttr & wfd.dwFileAttributes)))
    764         {
    765           if (IsAttribDir(ToAttr) || SHCreateDirectory(NULL,pTempTo))
     810        if (IsAttribDir((ToAttr & wfd.dwFileAttributes)))
     811        {
     812          if (IsAttribDir(ToAttr) || !SHCreateDirectoryExA(NULL,pTempTo, NULL))
    766813          {
    767814/*  ??? nlpFileOp.fFlags = (nlpFileOp.fFlags | FOF_MULTIDESTFILES); */
    768                   SHFileStrCpyCatA(pTempFrom, NULL, "\\*.*");
     815            SHFileStrCpyCatA(pTempFrom, NULL, "*.*");
    769816            retCode = SHFileOperationA(&nlpFileOp);
    770817          }
    771818          else
    772819          {
    773             nlpFileOp.fAnyOperationsAborted=TRUE;
    774820            retCode = 0x750;/* value unknown */
     821            goto shfileop_error;
    775822          }
    776823        }
     
    780827          && (not_overwrite))
    781828          {
    782             nlpFileOp.fAnyOperationsAborted=TRUE;
    783                   /* we need still the value for the returncode, we use the mostly assumed */
     829            /* we need still the value for the returncode, we use the mostly assumed */
    784830            retCode = 0x73;
    785831            goto shfileop_error;
     
    787833          if (!(CopyFileA(pTempFrom, pTempTo, FALSE)))
    788834          {
    789             nlpFileOp.fAnyOperationsAborted=TRUE;
    790835            retCode = 0x77; /* value unknown */
     836            goto shfileop_error;
    791837          }
    792838        }
     
    795841  }
    796842shfileop_normal:
    797         if (!(nlpFileOp.fAnyOperationsAborted))
    798           retCode = 0;
     843  if (!(nlpFileOp.fAnyOperationsAborted))
     844    retCode = 0;
    799845shfileop_error:
    800         if (hFind != INVALID_HANDLE_VALUE)
    801           FindClose(hFind);
     846  if (retCode)
     847    nlpFileOp.fAnyOperationsAborted = TRUE;
     848  if (hFind != INVALID_HANDLE_VALUE)
     849    FindClose(hFind);
    802850  hFind = INVALID_HANDLE_VALUE;
    803         if (pTempFrom)
    804           HeapFree(GetProcessHeap(), 0, pTempFrom);
     851  if (pTempFrom)
     852    HeapFree(GetProcessHeap(), 0, pTempFrom);
    805853
    806854  TRACE("%s level=%d AnyOpsAborted=%s ret=0x%x, with %s%s%s\n",
    807               pToFuncTXT, level, nlpFileOp.fAnyOperationsAborted ? "TRUE":"FALSE",
    808               retCode, debugstr_a(pFrom), pTo ? " -> ":"", debugstr_a(pTo));
     855        pToFuncTXT, level, nlpFileOp.fAnyOperationsAborted ? "TRUE":"FALSE",
     856        retCode, debugstr_a(pFrom), pTo ? " -> ":"", debugstr_a(pTo));
    809857
    810858  lpFileOp->fAnyOperationsAborted = nlpFileOp.fAnyOperationsAborted;
     
    840888 */
    841889HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v)
    842 {       FIXME("%p %p stub\n",u,v);
     890{  FIXME("%p %p stub\n",u,v);
     891  return 0;
     892}
     893
     894/*************************************************************************
     895 * SheChangeDirW [SHELL32.274]
     896 *
     897 */
     898HRESULT WINAPI SheChangeDirW(LPWSTR u)
     899{       FIXME("(%s),stub\n",debugstr_w(u));
    843900        return 0;
    844 }
    845 
    846 /*************************************************************************
    847  * SheChangeDir [SHELL32.@]
    848  *
    849  */
    850 HRESULT WINAPI SheChangeDirW(LPWSTR path)
    851 {       FIXME("(%s),stub\n",debugstr_w(path));
    852         return 0;
    853 }
    854 
    855 HRESULT WINAPI SheChangeDirA(LPSTR path)
    856 {
    857         WCHAR wPath[MAX_PATH];
    858        
    859         TRACE("(%s)\n", path);
    860 
    861         if (!path)
    862           return 0;
    863         MultiByteToWideChar(CP_ACP, 0, path, -1, wPath, MAX_PATH);
    864         return SheChangeDirW(wPath);
    865 }
    866 /*************************************************************************
    867  * SheChangeDirEx [SHELL32.@]
    868  *
    869  */
    870 HRESULT WINAPI SheChangeDirExW(LPWSTR path)
    871 {       FIXME("(%s),stub\n",debugstr_w(path));
    872         return 0;
    873 }
    874 
    875 HRESULT WINAPI SheChangeDirExA(LPSTR path)
    876 {
    877         WCHAR wPath[MAX_PATH];
    878        
    879         TRACE("(%s)\n", path);
    880 
    881         if (!path)
    882           return 0;
    883         MultiByteToWideChar(CP_ACP, 0, path, -1, wPath, MAX_PATH);
    884         return SheChangeDirExW(wPath);
    885901}
    886902
     
    895911  return (GetDriveTypeA(root) == DRIVE_REMOTE);
    896912}
     913
     914
Note: See TracChangeset for help on using the changeset viewer.