- Timestamp:
- Feb 15, 2003, 1:20:11 PM (23 years ago)
- Location:
- trunk/src/shell32
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/shell32/shlfileop.c
r9805 r9808 1 1 2 /* 2 3 * SHFileOperation … … 41 42 BOOL SHELL_ConfirmDialog (int nKindOfDialog, LPCSTR szDir) 42 43 { 43 44 44 char szCaption[255], szText[255], szBuffer[MAX_PATH + 256]; 45 UINT caption_resource_id, text_resource_id; 45 46 46 47 switch(nKindOfDialog) { … … 81 82 * like rm -r 82 83 */ 84 83 85 BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI) 84 86 { 85 BOOL ret = FALSE;86 HANDLE 87 BOOL ret = TRUE; 88 HANDLE hFind; 87 89 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, "*.*"); 94 94 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; 118 116 } 119 117 … … 124 122 BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI) 125 123 { 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 */ 135 static 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 148 static 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 161 BOOL 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 */ 173 static 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 196 static 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 219 BOOL 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 */ 235 static 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 255 static 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 275 DWORD WINAPI Win32DeleteFileAW(LPCVOID path) 276 { 277 if (SHELL_OsIsUnicode()) 278 return Win32DeleteFileW(path); 279 return Win32DeleteFileA(path); 129 280 } 130 281 … … 148 299 DWORD WINAPI SHCreateDirectoryExA(HWND hWnd, LPCSTR path, LPSECURITY_ATTRIBUTES sec) 149 300 { 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 */ 311 DWORD 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 } 159 336 return ret; 160 337 } 161 338 162 339 /************************************************************************* 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/2000187 */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 SHFileOperationA234 *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 /*************************************************************************260 340 * 261 341 * SHFileStrICmp HelperFunction for SHFileOperationA … … 265 345 { 266 346 CHAR C1 = '\0'; 267 CHAR C2 347 CHAR C2 = '\0'; 268 348 int i_Temp = -1; 269 270 349 int i_len1 = lstrlenA(p1); 350 int i_len2 = lstrlenA(p2); 271 351 272 352 if (p1End && (&p1[i_len1] >= p1End) && ('\\' == p1End[0])) … … 274 354 C1 = p1End[0]; 275 355 p1End[0] = '\0'; 276 356 i_len1 = lstrlenA(p1); 277 357 } 278 358 if (p2End) … … 294 374 } 295 375 } 296 297 298 i_Temp = lstrcmpiA(p1,p2); 376 i_len2 = lstrlenA(p2); 377 if (i_len1 == i_len2) 378 i_Temp = lstrcmpiA(p1,p2); 299 379 if (C1) 300 380 p1[i_len1] = C1; … … 303 383 return !(i_Temp); 304 384 } 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 309 395 /************************************************************************* 310 396 * SHFileOperationA [SHELL32.@] … … 344 430 BOOL b_Mask; /* wird als Schalter benutzt, vieleicht finde ich die richtige bitposition */ 345 431 BOOL b_ToTailSlash; 346 LPSTR pToFuncTXT; 432 433 LPCSTR cFO_Name [4] = { "FO_MOVE", "FO_COPY", "FO_DELETE", "FO_RENAME" }; 434 LPCSTR pToFuncTXT = "FO_????"; 347 435 348 436 long FuncSwitch = (nlpFileOp.wFunc & 0xf); … … 352 440 nlpFileOp.fAnyOperationsAborted=FALSE; 353 441 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)) 366 443 goto shfileop_normal; 367 } 368 444 445 pToFuncTXT = cFO_Name [FuncSwitch-1]; 369 446 if (level == 0) 370 447 TRACE("%s: flags (0x%04x) : %s%s%s%s%s%s%s%s%s%s%s%s \n",pToFuncTXT, nlpFileOp.fFlags, … … 399 476 * create dir 0 0 0 0 0 0 1 0 400 477 */ 401 /* 478 /* 402 479 * FOF_MULTIDESTFILES, FOF_NOCONFIRMATION, FOF_FILESONLY are implemented 403 480 * FOF_CONFIRMMOUSE, FOF_SILENT, FOF_NOCONFIRMMKDIR, FOF_SIMPLEPROGRESS are not implemented and ignored … … 405 482 * FOF_ALLOWUNDO, FOF_WANTMAPPINGHANDLE are not implemented and breaks 406 483 * if any other flag set, an error occurs 407 */ 484 */ 408 485 TRACE(__FUNCTION__" %s level=%d nlpFileOp.fFlags=0x%x\n", pToFuncTXT, level, lpFileOp->fFlags); 409 486 … … 418 495 { 419 496 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; 422 499 } 423 500 else … … 437 514 else 438 515 { 439 nlpFileOp.fAnyOperationsAborted=TRUE; 440 retCode = 0x402; 516 retCode = 0x402; /* 1026 */ 441 517 goto shfileop_error; 442 518 } … … 450 526 { 451 527 pTo = pNextTo; 452 528 pNextTo = &pNextTo[lstrlenA(pTo)+1]; 453 529 b_MultiTo = (b_Multi && pNextTo[0]); 454 530 } 455 531 456 532 pFrom = pNextFrom; 457 533 pNextFrom = &pNextFrom[lstrlenA(pNextFrom)+1]; 458 534 if (!b_MultiFrom && !b_MultiTo) 459 535 b_MultiFrom = (pNextFrom[0]); 460 536 461 537 pFromFile = SHFileStrCpyCatA(pTempFrom, pFrom, NULL); 462 538 463 539 if (pTo) 464 540 { 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 { 472 550 b_ToTailSlash = (!pToFile[1]); 473 551 if (b_ToTailSlash) … … 476 554 if (strchr(pTempTo,'\\')) 477 555 { 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],"*?")); 484 563 if (FO_RENAME == FuncSwitch) 485 564 { 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)) 489 568 { 490 569 /* no work, only RC=0 */ … … 493 572 } 494 573 } 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 */ 502 580 goto shfileop_error; 503 581 } /* endif */ … … 505 583 /* for all */ 506 584 #define HIGH_ADR (LPSTR)0xffffffff 507 585 // b_Mask = (!SHFileStrICmpA(&pFromFile[1], &wfd.cFileName[0], HIGH_ADR, HIGH_ADR)); 508 586 509 587 if (!pTo) /* FO_DELETE */ … … 513 591 if (wfd.cFileName[0] == '.') 514 592 { 515 516 517 518 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); 521 599 if (IsAttribFile(wfd.dwFileAttributes)) 522 600 { 523 601 nlpFileOp.fAnyOperationsAborted = (!Win32DeleteFileA(pTempFrom)); 524 602 retCode = 0x78; /* value unknown */ 525 603 } 526 604 else 527 605 { 528 nlpFileOp.fAnyOperationsAborted = (!SHELL_DeleteDirectoryA(pTempFrom, FALSE));529 retCode = 0x7 8; /* value unknown */606 nlpFileOp.fAnyOperationsAborted = (!SHELL_DeleteDirectoryA(pTempFrom,(!(nlpFileOp.fFlags & FOF_NOCONFIRMATION)))); 607 retCode = 0x79; /* value unknown */ 530 608 } 531 609 } while(!nlpFileOp.fAnyOperationsAborted && FindNextFileA(hFind, &wfd)); … … 540 618 541 619 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); 548 621 549 622 ToPathAttr = ToAttr = GetFileAttributesA(pTempTo); 550 if (!b_Mask && /* IsAttribDir(wfd.dwFileAttributes) && */(ToAttr -1))623 if (!b_Mask && (ToAttr -1)) 551 624 { 552 625 if (pToFile) … … 554 627 pToFile[0] = '\0'; 555 628 ToPathAttr = GetFileAttributesA(pTempTo); 556 /* if (-1 != ToPathAttr) */ pToFile[0] = '\\'; 557 } 558 } 629 pToFile[0] = '\\'; 630 } 631 } 632 559 633 if (FO_RENAME == FuncSwitch) 560 634 { 561 635 if (!b_SameRoot || b_Mask /* FO_RENAME works not with Mask */ 562 563 636 || !SHFileStrICmpA(pTempFrom, pTempTo, pFromFile, NULL) 637 || (SHFileStrICmpA(pTempFrom, pTempTo, pFromFile, HIGH_ADR) && !b_ToTailSlash)) 564 638 { 565 639 retCode = 0x73; 566 nlpFileOp.fAnyOperationsAborted=TRUE;567 640 goto shfileop_error; 568 641 } 569 642 if (b_ToInvalidTail) 570 643 { 571 nlpFileOp.fAnyOperationsAborted=TRUE;572 644 retCode=0x2; 573 645 goto shfileop_error; 574 646 } 647 if (-1 == ToPathAttr) 648 { 649 retCode = 0x75; 650 goto shfileop_error; 651 } 575 652 if (IsAttribDir(wfd.dwFileAttributes) && IsAttribDir(ToAttr)) 576 653 { 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; 592 655 goto shfileop_error; 593 656 } /* endif */ 594 657 if (!MoveFileA(pTempFrom, pTempTo)) 595 658 { 596 nlpFileOp.fAnyOperationsAborted=TRUE;597 659 /* we need still the value for the returncode, we use the mostly assumed */ 598 660 retCode = 0xb7; 599 661 goto shfileop_error; 600 662 } … … 602 664 } 603 665 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 knnte 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)); 630 670 631 671 /* handle mask in source */ … … 634 674 if (!IsAttribDir(ToAttr)) 635 675 { 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; 645 678 goto shfileop_error; 646 679 } 647 680 pToFile = SHFileStrCpyCatA(pTempTo,NULL, "\\"); 648 681 nlpFileOp.fFlags = (nlpFileOp.fFlags | FOF_MULTIDESTFILES); 649 682 do … … 659 692 continue; /* next name in pTempFrom(dir) */ 660 693 } 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); 663 696 retCode = SHFileOperationA (&nlpFileOp); 664 697 } while(!nlpFileOp.fAnyOperationsAborted && FindNextFileA(hFind, &wfd)); … … 670 703 continue; 671 704 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 672 730 /* tailling BackSlash is ever removed and pToFile points to BackSlash before */ 673 731 if (!b_MultiTo && (b_MultiFrom || (!(b_Multi) && IsAttribDir(ToAttr)))) … … 677 735 if (b_Multi) 678 736 { 679 retCode = 0x73; /* !b_Multi = 0x8 ?? */ 680 nlpFileOp.fAnyOperationsAborted=TRUE; 737 retCode = 0x73; /* !b_Multi = 0x8 ?? */ 681 738 goto shfileop_error; 682 739 } 683 740 } 684 pToFile = SHFileStrCpyCatA(&pTempTo[strlen(pTempTo)], "\\", wfd.cFileName);741 pToFile = SHFileStrCpyCatA(pTempTo, NULL, wfd.cFileName); 685 742 ToAttr = GetFileAttributesA(pTempTo); 686 743 } … … 690 747 if (IsAttribFile(wfd.dwFileAttributes)) 691 748 { 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; 701 750 goto shfileop_error; 702 751 } … … 709 758 if (IsAttribFile(ToPathAttr)) 710 759 { 711 /* fehler, ist das schon getestet ? */ 712 nlpFileOp.fAnyOperationsAborted=TRUE; 760 /* error, is this tested ? */ 713 761 retCode = 0x777402; 714 762 goto shfileop_error; … … 720 768 { 721 769 /* Target-dir does not exist, and can not created */ 722 nlpFileOp.fAnyOperationsAborted=TRUE;723 770 retCode=0x75; 724 771 goto shfileop_error; … … 728 775 { 729 776 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 { 732 780 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; 733 800 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 */ 754 802 continue; 755 803 case FO_COPY: 756 804 if (SHFileStrICmpA(pTempFrom, pTempTo, NULL, NULL)) 757 805 { /* target is the same as source ? */ 758 nlpFileOp.fAnyOperationsAborted=TRUE;759 806 /* we need still the value for the returncode, we assume 0x71 */ 760 807 retCode = 0x71; 761 808 goto shfileop_error; 762 809 } /* endif */ 763 764 { 765 if (IsAttribDir(ToAttr) || SHCreateDirectory(NULL,pTempTo))810 if (IsAttribDir((ToAttr & wfd.dwFileAttributes))) 811 { 812 if (IsAttribDir(ToAttr) || !SHCreateDirectoryExA(NULL,pTempTo, NULL)) 766 813 { 767 814 /* ??? nlpFileOp.fFlags = (nlpFileOp.fFlags | FOF_MULTIDESTFILES); */ 768 SHFileStrCpyCatA(pTempFrom, NULL, "\\*.*");815 SHFileStrCpyCatA(pTempFrom, NULL, "*.*"); 769 816 retCode = SHFileOperationA(&nlpFileOp); 770 817 } 771 818 else 772 819 { 773 nlpFileOp.fAnyOperationsAborted=TRUE;774 820 retCode = 0x750;/* value unknown */ 821 goto shfileop_error; 775 822 } 776 823 } … … 780 827 && (not_overwrite)) 781 828 { 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 */ 784 830 retCode = 0x73; 785 831 goto shfileop_error; … … 787 833 if (!(CopyFileA(pTempFrom, pTempTo, FALSE))) 788 834 { 789 nlpFileOp.fAnyOperationsAborted=TRUE;790 835 retCode = 0x77; /* value unknown */ 836 goto shfileop_error; 791 837 } 792 838 } … … 795 841 } 796 842 shfileop_normal: 797 798 843 if (!(nlpFileOp.fAnyOperationsAborted)) 844 retCode = 0; 799 845 shfileop_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); 802 850 hFind = INVALID_HANDLE_VALUE; 803 804 851 if (pTempFrom) 852 HeapFree(GetProcessHeap(), 0, pTempFrom); 805 853 806 854 TRACE("%s level=%d AnyOpsAborted=%s ret=0x%x, with %s%s%s\n", 807 808 855 pToFuncTXT, level, nlpFileOp.fAnyOperationsAborted ? "TRUE":"FALSE", 856 retCode, debugstr_a(pFrom), pTo ? " -> ":"", debugstr_a(pTo)); 809 857 810 858 lpFileOp->fAnyOperationsAborted = nlpFileOp.fAnyOperationsAborted; … … 840 888 */ 841 889 HRESULT 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 */ 898 HRESULT WINAPI SheChangeDirW(LPWSTR u) 899 { FIXME("(%s),stub\n",debugstr_w(u)); 843 900 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);885 901 } 886 902 … … 895 911 return (GetDriveTypeA(root) == DRIVE_REMOTE); 896 912 } 913 914
Note:
See TracChangeset
for help on using the changeset viewer.