- Timestamp:
- Sep 24, 2001, 9:19:43 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/shell32/shlfileop.c
r6709 r6800 196 196 LPSTR pTo = (LPSTR)lpFileOp->pTo; 197 197 #ifdef __WIN32OS2__ 198 DWORD FromAttr; 199 DWORD ToAttr; 200 LPSTR pTempFrom = NULL; 201 LPSTR pTempTo; 202 LPSTR pFromFile; 203 LPSTR pToFile; 204 205 FILEOP_FLAGS OFl = ((FILEOP_FLAGS)lpFileOp->fFlags & 0x7ff); 206 BOOL Multi = TRUE; 207 BOOL withFileName; 208 BOOL not_overwrite; 209 BOOL ToSingle; 210 BOOL BothDir; 211 BOOL ToWithoutBackSlash; 212 long lenFrom = -1; 213 long lenTo = -1; 214 long lenTempFrom; 215 long lenTempTo; 216 long retCode = 0x75; 217 long TempretCode = 0; 218 long where = 0; 219 SHFILEOPSTRUCTA nlpFileOp = *(lpFileOp); 220 HANDLE hFind; 221 WIN32_FIND_DATAA wfd; 198 DWORD FromAttr; 199 DWORD ToAttr; 200 LPSTR pTempFrom = NULL; 201 LPSTR pTempTo; 202 LPSTR pFromFile; 203 LPSTR pToFile; 204 205 FILEOP_FLAGS OFl = ((FILEOP_FLAGS)lpFileOp->fFlags & 0x7ff); 206 BOOL Multi = TRUE; 207 BOOL withFileName; 208 BOOL not_overwrite; 209 BOOL ToSingle; 210 BOOL BothDir; 211 BOOL ToWithoutBackSlash; 212 long lenFrom = -1; 213 long lenTo = -1; 214 long lenTempFrom; 215 long lenTempTo; 216 long retCode = 0x75; 217 long TempretCode = 0; 218 long where = 0; 219 SHFILEOPSTRUCTA nlpFileOp = *(lpFileOp); 220 long level= nlpFileOp.wFunc>>4; 221 HANDLE hFind; 222 WIN32_FIND_DATAA wfd; 222 223 223 224 /* default no error … … 225 226 lpFileOp->fAnyOperationsAborted=FALSE; 226 227 nlpFileOp.fAnyOperationsAborted=FALSE; 228 level++; 229 nlpFileOp.wFunc = (level<<4) + (lpFileOp->wFunc & 15); 227 230 #else 228 231 LPSTR pTempTo; 229 232 #endif 230 233 #ifdef __WIN32OS2__ 234 switch(lpFileOp->wFunc & 15) { 235 #else 231 236 switch(lpFileOp->wFunc) { 237 #endif 232 238 case FO_COPY: 233 TRACE("File Copy:\n"); 234 #ifdef __WIN32OS2__ 235 pTempFrom = HeapAlloc(GetProcessHeap(), 0, 3 * MAX_PATH+6); 236 pTempTo = &pTempFrom[MAX_PATH+4]; 239 #ifdef __WIN32OS2__ 240 pTempFrom = HeapAlloc(GetProcessHeap(), 0, 3 * MAX_PATH+6); 241 pTempTo = &pTempFrom[MAX_PATH+4]; 237 242 /* 238 * FOF_MULTIDESTFILES, FOF_NOCONFIRMATION, FOF_FILESONLY are implemented 239 * FOF_CONFIRMMOUSE, FOF_SILENT, FOF_NOCONFIRMMKDIR, FOF_SIMPLEPROGRESS are not implemented and ignored 243 * FOF_MULTIDESTFILES, FOF_NOCONFIRMATION, FOF_FILESONLY are implemented 244 * FOF_CONFIRMMOUSE, FOF_SILENT, FOF_NOCONFIRMMKDIR, FOF_SIMPLEPROGRESS are not implemented and ignored 245 * FOF_RENAMEONCOLLISION are implemented partially and breaks if file exist 246 * FOF_ALLOWUNDO, FOF_WANTMAPPINGHANDLE are not implemented and breaks 240 247 * if any other flag set, an error occurs 241 248 */ 242 OFl = (OFl & (-1 - (FOF_MULTIDESTFILES | FOF_FILESONLY))); 243 OFl = (OFl ^ (FOF_SILENT | FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOCONFIRMMKDIR)); 244 if (OFl) { 245 if (OFl & (-1 - (FOF_CONFIRMMOUSE | FOF_SILENT | FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOCONFIRMMKDIR))) { 246 FIXME(__FUNCTION__" FO_COPY with this fFlags not implemented:%x ,stub\n",lpFileOp->fFlags); 247 lpFileOp->fAnyOperationsAborted=TRUE; 248 } else { 249 // not FOF_SILENT, not FOF_SIMPLEPROGRESS, not FOF_NOCONFIRMMKDIR 250 FIXME(__FUNCTION__" FO_COPY with this lpFileOp->fFlags not full implemented:0x%x ,stub\n",lpFileOp->fFlags); 251 } /* endif */ 252 } /* endif */ 253 254 not_overwrite = (!(lpFileOp->fFlags & FOF_NOCONFIRMATION)); 249 TRACE(__FUNCTION__" FO_COPY level=%d lpFileOp->fFlags=0x%x\n",level ,lpFileOp->fFlags); 250 // OFl = (OFl & (-1 - (FOF_MULTIDESTFILES | FOF_FILESONLY))); 251 // OFl = (OFl ^ (FOF_SILENT | FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOCONFIRMMKDIR)); 252 OFl = (OFl & ( ~ (FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | FOF_FILESONLY))); // implemented 253 OFl = (OFl ^ (FOF_SILENT | FOF_NOCONFIRMMKDIR)); // ignored, if one 254 OFl = (OFl & ( ~ FOF_SIMPLEPROGRESS)); // ignored, only with FOF_SILENT 255 if (OFl) { 256 if (OFl & ( ~ (FOF_CONFIRMMOUSE | FOF_SILENT | FOF_RENAMEONCOLLISION | FOF_NOCONFIRMMKDIR))) { 257 TRACE(__FUNCTION__" FO_COPY level=%d lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n", level, OFl); 258 nlpFileOp.fAnyOperationsAborted=TRUE; 259 } else { 260 TRACE(__FUNCTION__" FO_COPY level=%d lpFileOp->fFlags=0x%x not full implemented ,stub\n", level, OFl); 261 } /* endif */ 262 } /* endif */ 263 264 not_overwrite = (!(lpFileOp->fFlags & FOF_NOCONFIRMATION) || (lpFileOp->fFlags & FOF_RENAMEONCOLLISION)); 255 265 256 266 // fix for more then one source for one target 257 267 pToFile = pTempTo; 258 268 259 269 // need break at error before change sourcepointer 260 261 262 270 while(!nlpFileOp.fAnyOperationsAborted && (pFrom+=lenFrom+1)[0]) { 271 272 if (!withFileName && Multi && (pTo[lenTo+1]=='\0')) { 263 273 // Win Bug ? 264 265 266 267 268 269 270 271 272 273 274 TRACE(" From='%s' To='%s'\n", pFrom, pTo);274 Multi = FALSE; 275 } /* endif */ 276 277 if (Multi) pTo += lenTo + 1; 278 if(!pTo[0]) { 279 nlpFileOp.fAnyOperationsAborted=TRUE; 280 where = 213; 281 break; 282 } 283 284 TRACE(__FUNCTION__" FO_COPY level=%d From='%s' To='%s'\n", level, pFrom, pTo); 275 285 276 286 // fix for more then one source for one target 277 278 279 280 281 282 283 284 285 287 pToFile[0] = '\0'; 288 nlpFileOp.pTo = pTo; 289 290 lenFrom=strlen(pFrom); 291 strcpy(pTempFrom,pFrom); 292 FromAttr = GetFileAttributesA(pTempFrom); 293 294 if (Multi) { 295 lenTo = strlen(pTo); 286 296 // single targetdir !Multi 287 297 Multi = (Multi && (lpFileOp->fFlags & FOF_MULTIDESTFILES)); 288 298 // multi target, each one for one source. ? last target + more than one source (all source files an one dir as target) 289 299 290 291 292 293 294 295 296 297 BothDir = (Multi&&298 ToWithoutBackSlash&&299 (-1 != (FromAttr | ToAttr))&&300 301 302 withFileName = (!BothDir&&303 304 305 306 300 ToSingle = ((pTo[lenTo+1]=='\0') || !Multi); 301 302 strcpy(pTempTo,pTo); 303 PathRemoveBackslashA(pTempTo); 304 ToWithoutBackSlash = (strlen(pTempTo)==lenTo); 305 ToAttr = GetFileAttributesA(pTempTo); 306 307 BothDir = (Multi && 308 ToWithoutBackSlash && 309 (-1 != (FromAttr | ToAttr)) && 310 (ToAttr & FromAttr & FILE_ATTRIBUTE_DIRECTORY)); 311 312 withFileName = (!BothDir && 313 (ToWithoutBackSlash || !ToSingle) && 314 (ToAttr == -1 || !(ToAttr & FILE_ATTRIBUTE_DIRECTORY))); 315 316 if (withFileName) { 307 317 // Target must not be an directory 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 318 PathRemoveFileSpecA(pTempTo); 319 ToAttr = GetFileAttributesA(pTempTo); 320 } 321 if ((ToAttr == -1) || 322 !(ToAttr & FILE_ATTRIBUTE_DIRECTORY) || 323 (!withFileName && !ToSingle) ) { 324 nlpFileOp.fAnyOperationsAborted=TRUE; 325 where = 201; 326 break; 327 } 328 lenTempTo = strlen(pTempTo); 329 withFileName = (((lenTempTo + 1) < lenTo) || (PathIsRootA(pTo) && lenTempTo < lenTo)); 330 PathAddBackslashA(pTempTo); 331 } 332 333 if (FromAttr == -1 || BothDir) { 324 334 // is Source an existing directory\*.* ? 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 335 if (FromAttr == -1) { 336 PathRemoveFileSpecA(pTempFrom); 337 FromAttr = GetFileAttributesA(pTempFrom); 338 } 339 340 PathAddBackslashA(pTempFrom); 341 lenTempFrom = strlen(pTempFrom); 342 pFromFile=&pTempFrom[lenTempFrom]; 343 344 if (FromAttr == -1 || 345 ((lenTempFrom==lenFrom) && !PathIsRootA(pFrom)) || 346 !(FromAttr & FILE_ATTRIBUTE_DIRECTORY) || 347 !((0==strcmp(&pFrom[lenTempFrom],"*.*")) || BothDir)) { 348 retCode=0x402; 349 nlpFileOp.fAnyOperationsAborted=TRUE; 350 where = 202; 351 break; 352 } 353 354 strcpy(pFromFile, "*.*"); 355 hFind = FindFirstFileA(pTempFrom, &wfd); 356 if (INVALID_HANDLE_VALUE == hFind) { 357 nlpFileOp.fAnyOperationsAborted=TRUE; 358 retCode=0x79; 359 where = 203; 360 break; 361 } 362 363 nlpFileOp.pFrom = pTempFrom; 354 364 // single copy never with FOF_MULTIDESTFILES, I can use lpFileOp->pTo as nlpFileOp.pTo, 355 365 // I need no different targetarea for the name 356 nlpFileOp.fFlags = (nlpFileOp.fFlags & (-1 - (FOF_MULTIDESTFILES))); 357 358 TRACE(__FUNCTION__" Copy between Subdir %s -> %s'\n", nlpFileOp.pFrom, nlpFileOp.pTo); 359 360 do { 361 TRACE(__FUNCTION__" find '%s'\n", wfd.cFileName); 362 if (0==strcmp(wfd.cFileName,".")) continue; 363 if (0==strcmp(wfd.cFileName,"..")) continue; 364 if ((nlpFileOp.fFlags & FOF_FILESONLY) && (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)) { 365 continue; 366 } /* endif */ 367 368 strcpy(pFromFile,wfd.cFileName); 369 pTempFrom[strlen(pTempFrom)+1]='\0'; 370 371 TempretCode = SHFileOperationA (&nlpFileOp); 372 373 if (nlpFileOp.fAnyOperationsAborted) {where = 204;break;} 374 375 } while(FindNextFileA(hFind, &wfd)); 376 377 FindClose(hFind); 378 if (nlpFileOp.fAnyOperationsAborted) {where = 205;break;} 379 continue; 380 } 381 382 lenTempTo = strlen(pTempTo); 383 pToFile = &pTempTo[lenTempTo]; 366 TRACE(__FUNCTION__" FO_COPY level=%d Copy between Subdir %s -> %s'\n",level ,nlpFileOp.pFrom, nlpFileOp.pTo); 367 nlpFileOp.fFlags = (nlpFileOp.fFlags & (-1 - (FOF_MULTIDESTFILES))); 368 369 do { 370 TRACE(__FUNCTION__" FO_COPY level=%d find '%s'\n",level ,wfd.cFileName); 371 if (0==strcmp(wfd.cFileName,".")) continue; 372 if (0==strcmp(wfd.cFileName,"..")) continue; 373 if ((nlpFileOp.fFlags & FOF_FILESONLY) && (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)) { 374 continue; 375 } /* endif */ 376 377 strcpy(pFromFile,wfd.cFileName); 378 pTempFrom[strlen(pTempFrom)+1]='\0'; 379 380 TempretCode = SHFileOperationA (&nlpFileOp); 381 382 if (nlpFileOp.fAnyOperationsAborted) {where = 204;break;} 383 384 } while(FindNextFileA(hFind, &wfd)); 385 386 FindClose(hFind); 387 if (nlpFileOp.fAnyOperationsAborted) {where = 205;break;} 388 continue; 389 } 390 391 lenTempTo = strlen(pTempTo); 392 pToFile = &pTempTo[lenTempTo]; 384 393 // Check Source 385 386 387 388 389 390 391 392 394 strcpy(pToFile,pTempFrom); 395 PathRemoveBackslashA(pToFile); 396 if (strlen(pToFile)<lenFrom) { 397 nlpFileOp.fAnyOperationsAborted=TRUE; 398 retCode=0x402; 399 where = 206; 400 break; 401 } /* endif */ 393 402 394 403 // target name in target or from source 395 396 397 398 399 400 404 pFromFile = NULL; 405 if (withFileName) { 406 if ((pFrom[lenFrom+1]=='\0') || (Multi && !(pTo[lenTo+1]=='\0'))) { 407 pFromFile = pTo; 408 } /* endif */ 409 } else { 401 410 // Multi Target 402 411 if (!Multi || !(pFrom[lenFrom+1]=='\0') || 403 412 // only target+\, target without \ has 0x402 404 405 406 407 408 409 410 411 412 413 413 (Multi && (FromAttr & ToAttr & FILE_ATTRIBUTE_DIRECTORY))) { 414 pFromFile = pTempFrom; 415 } 416 } /* endif */ 417 418 if (!pFromFile) { 419 nlpFileOp.fAnyOperationsAborted=TRUE; 420 where = 207; 421 break; 422 } /* endif */ 414 423 415 424 // move isolated target filename 416 417 418 419 420 421 422 423 424 FIXME(__FUNCTION__" FO_COPY with Source %s not implementiert ,stub\n",pTempFrom);425 426 427 428 429 430 425 strcpy(pToFile,pFromFile); 426 PathRemoveFileSpecA(pToFile); 427 PathAddBackslashA(pToFile); 428 429 strcpy(pToFile,&pFromFile[strlen(pToFile)]); 430 ToAttr = GetFileAttributesA(pTempTo); 431 432 if (FromAttr == -1) { 433 TRACE(__FUNCTION__" FO_COPY level=%d with Source %s not implementiert ,stub\n",level ,pTempFrom); 434 nlpFileOp.fAnyOperationsAborted=TRUE; 435 where = 208; 436 break; 437 } 438 if (FromAttr & FILE_ATTRIBUTE_DIRECTORY) { 439 if (ToAttr == -1) { 431 440 // Try to create an new Directory and enter in it 432 TRACE(" Creating Directory '%s'\n", pTempTo);433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 TRACE(__FUNCTION__" Entering Directory '%s'\n", nlpFileOp.pTo);453 454 455 456 457 458 459 FIXME(__FUNCTION__" FO_COPY unexpected with %s -> %s ? ,stub\n",pTempFrom,pTo);460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 441 TRACE(__FUNCTION__" FO_COPY level=%d Creating Directory '%s'\n",level , pTempTo); 442 SHCreateDirectory(NULL,pTempTo); 443 ToAttr = GetFileAttributesA(pTempTo); 444 if (ToAttr == -1) { 445 nlpFileOp.fAnyOperationsAborted=TRUE; 446 retCode=0x10003; 447 where = 209; 448 break; 449 } 450 451 lenTempTo = strlen(pTempTo); 452 453 PathAddBackslashA(pTempFrom); 454 strcat(pTempFrom, "*.*"); 455 pTempFrom[strlen(pTempFrom)+1]='\0'; 456 nlpFileOp.pFrom = pTempFrom; 457 458 pTempTo[lenTempTo+1]='\0'; 459 nlpFileOp.pTo = pTempTo; 460 461 TRACE(__FUNCTION__" FO_COPY level=%d Entering Directory '%s'\n",level , nlpFileOp.pTo); 462 TempretCode = SHFileOperationA (&nlpFileOp); 463 464 if (nlpFileOp.fAnyOperationsAborted) {break;} 465 continue; 466 467 } else { 468 TRACE(__FUNCTION__" FO_COPY level=%d unexpected with %s -> %s ? ,stub\n",level ,pTempFrom,pTo); 469 nlpFileOp.fAnyOperationsAborted=TRUE; 470 where = 210; 471 retCode=0x77; 472 break; 473 474 } 475 476 } 477 478 if (!(ToAttr == -1) && (ToAttr & FILE_ATTRIBUTE_DIRECTORY)) { 479 nlpFileOp.fAnyOperationsAborted=TRUE; 480 where = 211; 481 break; 482 } 483 if (0==strcmp(pTempFrom, pTempTo)) { 484 nlpFileOp.fAnyOperationsAborted=TRUE; 485 retCode = 0x71; 486 where = 212; 487 break; 488 } 480 489 // first try to copy 481 482 483 if (not_overwrite) {484 490 if (CopyFileA(pTempFrom, pTempTo, not_overwrite)) continue; 491 492 if ((not_overwrite) && !(lpFileOp->fFlags & FOF_RENAMEONCOLLISION)) { 493 if (SHELL_ConfirmDialog (ASK_OVERWRITE_FILE, pTempTo)) 485 494 // second try to copy after confirm 486 487 488 489 490 491 492 495 if (CopyFileA(pTempFrom, pTempTo, FALSE)) continue; 496 } /* endif */ 497 498 nlpFileOp.fAnyOperationsAborted=TRUE; 499 where = 215; 500 } 501 break; 493 502 #else 494 503 while(1) { … … 517 526 518 527 case FO_DELETE: 528 #ifdef __WIN32OS2__ 529 TRACE(__FUNCTION__" FO_DELETE level=%d\n",level); 530 // need break at error before change sourcepointer 531 while(!nlpFileOp.fAnyOperationsAborted && (pFrom+=lenFrom+1)[0]) { 532 lenFrom=strlen(pFrom); 533 FromAttr = GetFileAttributesA(pFrom); 534 if (!(FromAttr & FILE_ATTRIBUTE_DIRECTORY)) { 535 TRACE(__FUNCTION__" FO_DELETE level=%d File='%s'\n",level , pFrom); 536 if (DeleteFileA(pFrom)) continue; 537 nlpFileOp.fAnyOperationsAborted=TRUE; 538 // retCode = 0x71; 539 where = 301; 540 break; 541 } 542 if (!(pTempFrom)) pTempFrom = HeapAlloc(GetProcessHeap(), 0, MAX_PATH+2); 543 strcpy(pTempFrom,pFrom); 544 PathRemoveBackslashA(pTempFrom); 545 FromAttr = GetFileAttributesA(pTempFrom); 546 if (!(FromAttr & FILE_ATTRIBUTE_DIRECTORY) ) { 547 nlpFileOp.fAnyOperationsAborted=TRUE; 548 // retCode = 0x71; 549 where = 302; 550 break; 551 } 552 // is Source an existing directory\*.* ? 553 if (FromAttr == -1) { 554 PathRemoveFileSpecA(pTempFrom); 555 FromAttr = GetFileAttributesA(pTempFrom); 556 } 557 558 PathAddBackslashA(pTempFrom); 559 lenTempFrom = strlen(pTempFrom); 560 pFromFile=&pTempFrom[lenTempFrom]; 561 562 if (FromAttr == -1 || 563 ((lenTempFrom==lenFrom) && !PathIsRootA(pFrom)) || 564 !(FromAttr & FILE_ATTRIBUTE_DIRECTORY) || 565 !(('\0'==pFrom[lenTempFrom]) || (0==strcmp(&pFrom[lenTempFrom],"*.*"))) ) { 566 retCode=0x402; 567 nlpFileOp.fAnyOperationsAborted=TRUE; 568 where = 303; 569 break; 570 } 571 strcpy(pFromFile, "*.*"); 572 lenTempFrom = strlen(pTempFrom); 573 if (lenFrom < lenTempFrom) { 574 // Source is without \*.* 575 pTempFrom[lenTempFrom+1]='\0'; 576 nlpFileOp.pFrom = pTempFrom; 577 578 TRACE(__FUNCTION__" FO_DELETE level=%d Entering Directory '%s'\n",level , nlpFileOp.pFrom); 579 TempretCode = SHFileOperationA (&nlpFileOp); 580 581 if (nlpFileOp.fAnyOperationsAborted) {break;} 582 // Call SHELL_DeleteDirectoryA ? 583 if (RemoveDirectoryA(pFrom)) continue; 584 nlpFileOp.fAnyOperationsAborted=TRUE; 585 where = 304; 586 break; 587 } 588 hFind = FindFirstFileA(pTempFrom, &wfd); 589 if (INVALID_HANDLE_VALUE == hFind) { 590 nlpFileOp.fAnyOperationsAborted=TRUE; 591 retCode=0x79; 592 where = 303; 593 break; 594 } 595 596 nlpFileOp.pFrom = pTempFrom; 597 598 nlpFileOp.fFlags = (nlpFileOp.fFlags & (-1 - (FOF_MULTIDESTFILES))); 599 600 TRACE(__FUNCTION__" FO_DELETE level=%d Delete in Subdir %s'\n",level , nlpFileOp.pFrom); 601 602 do { 603 TRACE(__FUNCTION__" FO_DELETE level=%d find '%s'\n",level , wfd.cFileName); 604 if (0==strcmp(wfd.cFileName,".")) continue; 605 if (0==strcmp(wfd.cFileName,"..")) continue; 606 if ((nlpFileOp.fFlags & FOF_FILESONLY) && (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)) { 607 continue; 608 } /* endif */ 609 610 strcpy(pFromFile,wfd.cFileName); 611 pTempFrom[strlen(pTempFrom)+1]='\0'; 612 613 TempretCode = SHFileOperationA (&nlpFileOp); 614 615 if (nlpFileOp.fAnyOperationsAborted) {where = 304;break;} 616 617 } while(FindNextFileA(hFind, &wfd)); 618 619 FindClose(hFind); 620 if (nlpFileOp.fAnyOperationsAborted) {where = 305;break;} 621 continue; 622 } 623 break; 624 case FO_MOVE: 625 TRACE(__FUNCTION__" FO_MOVE level=%d File\\Tree Move: simply (Copy/Delete)\n",level); 626 nlpFileOp.wFunc = (level<<4) + FO_COPY; 627 // not delete at error from copy 628 TempretCode = SHFileOperationA (&nlpFileOp); 629 630 if (nlpFileOp.fAnyOperationsAborted) { 631 if (TempretCode == 0x75) { 632 // not all, the most 633 TempretCode = 0xD7; 634 retCode = 0xD7; 635 } /* endif */ 636 break; 637 } 638 639 nlpFileOp.wFunc = (level<<4) + FO_DELETE; 640 641 TempretCode = SHFileOperationA (&nlpFileOp); 642 643 case 0: 644 break; 645 #else 519 646 TRACE("File Delete:\n"); 520 #ifdef __WIN32OS2__521 // need break at error before change sourcepointer522 while(!nlpFileOp.fAnyOperationsAborted && (pFrom+=lenFrom+1)[0]) {523 lenFrom=strlen(pFrom);524 FromAttr = GetFileAttributesA(pFrom);525 if (!(FromAttr & FILE_ATTRIBUTE_DIRECTORY)) {526 TRACE(" File='%s'\n", pFrom);527 if (DeleteFileA(pFrom)) continue;528 nlpFileOp.fAnyOperationsAborted=TRUE;529 // retCode = 0x71;530 where = 301;531 break;532 }533 if (!(pTempFrom)) pTempFrom = HeapAlloc(GetProcessHeap(), 0, MAX_PATH+2);534 strcpy(pTempFrom,pFrom);535 PathRemoveBackslashA(pTempFrom);536 FromAttr = GetFileAttributesA(pTempFrom);537 if (!(FromAttr & FILE_ATTRIBUTE_DIRECTORY) ) {538 nlpFileOp.fAnyOperationsAborted=TRUE;539 // retCode = 0x71;540 where = 302;541 break;542 }543 // is Source an existing directory\*.* ?544 if (FromAttr == -1) {545 PathRemoveFileSpecA(pTempFrom);546 FromAttr = GetFileAttributesA(pTempFrom);547 }548 549 PathAddBackslashA(pTempFrom);550 lenTempFrom = strlen(pTempFrom);551 pFromFile=&pTempFrom[lenTempFrom];552 553 if (FromAttr == -1 ||554 ((lenTempFrom==lenFrom) && !PathIsRootA(pFrom)) ||555 !(FromAttr & FILE_ATTRIBUTE_DIRECTORY) ||556 !(('\0'==pFrom[lenTempFrom]) || (0==strcmp(&pFrom[lenTempFrom],"*.*"))) ) {557 retCode=0x402;558 nlpFileOp.fAnyOperationsAborted=TRUE;559 where = 303;560 break;561 }562 strcpy(pFromFile, "*.*");563 lenTempFrom = strlen(pTempFrom);564 if (lenFrom < lenTempFrom) {565 // Source is without \*.*566 pTempFrom[lenTempFrom+1]='\0';567 nlpFileOp.pFrom = pTempFrom;568 569 TRACE(__FUNCTION__" Entering Directory '%s'\n", nlpFileOp.pFrom);570 TempretCode = SHFileOperationA (&nlpFileOp);571 572 if (nlpFileOp.fAnyOperationsAborted) {break;}573 // Call SHELL_DeleteDirectoryA ?574 if (RemoveDirectoryA(pFrom)) continue;575 nlpFileOp.fAnyOperationsAborted=TRUE;576 where = 304;577 break;578 }579 hFind = FindFirstFileA(pTempFrom, &wfd);580 if (INVALID_HANDLE_VALUE == hFind) {581 nlpFileOp.fAnyOperationsAborted=TRUE;582 retCode=0x79;583 where = 303;584 break;585 }586 587 nlpFileOp.pFrom = pTempFrom;588 // single copy never with FOF_MULTIDESTFILES, I can use lpFileOp->pTo as nlpFileOp.pTo,589 // I need no different targetarea for the name590 nlpFileOp.fFlags = (nlpFileOp.fFlags & (-1 - (FOF_MULTIDESTFILES)));591 592 TRACE(__FUNCTION__" Delete in Subdir %s'\n", nlpFileOp.pFrom);593 594 do {595 TRACE(__FUNCTION__" find '%s'\n", wfd.cFileName);596 if (0==strcmp(wfd.cFileName,".")) continue;597 if (0==strcmp(wfd.cFileName,"..")) continue;598 if ((nlpFileOp.fFlags & FOF_FILESONLY) && (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)) {599 continue;600 } /* endif */601 602 strcpy(pFromFile,wfd.cFileName);603 pTempFrom[strlen(pTempFrom)+1]='\0';604 605 TempretCode = SHFileOperationA (&nlpFileOp);606 607 if (nlpFileOp.fAnyOperationsAborted) {where = 304;break;}608 609 } while(FindNextFileA(hFind, &wfd));610 611 FindClose(hFind);612 if (nlpFileOp.fAnyOperationsAborted) {where = 305;break;}613 continue;614 }615 break;616 case FO_MOVE:617 TRACE("File\\Tree Move: simply (Copy/Delete)\n");618 nlpFileOp.wFunc = FO_COPY;619 // not delete at error from copy620 TempretCode = SHFileOperationA (&nlpFileOp);621 622 if (nlpFileOp.fAnyOperationsAborted) {623 if (TempretCode == 0x75) {624 // not all, the most625 TempretCode = 0xD7;626 retCode = 0xD7;627 } /* endif */628 break;629 }630 631 nlpFileOp.wFunc = FO_DELETE;632 633 TempretCode = SHFileOperationA (&nlpFileOp);634 635 case 0:636 break;637 #else638 647 while(1) { 639 648 if(!pFrom[0]) break; … … 649 658 default: 650 659 #ifdef __WIN32OS2__ 651 FIXME(__FUNCTION__" Unhandled shell file operation %d stub\n", lpFileOp->wFunc); 660 TRACE(__FUNCTION__" Unhandled shell file operation %d at level=%d stub\n",(lpFileOp->wFunc & 15), level ); 661 lpFileOp->fAnyOperationsAborted=TRUE; 652 662 #else 653 663 FIXME("Unhandled shell file operation %d\n", lpFileOp->wFunc); … … 658 668 #ifdef __WIN32OS2__ 659 669 } 660 661 662 663 664 665 666 667 668 669 if (FO_DELETE == lpFileOp->wFunc) {670 TRACE(__FUNCTION__" Setting AnyOpsAborted=TRUE ret=0x%x, at=%i with %s\n",retCode,where,pFrom);671 672 TRACE(__FUNCTION__" Setting AnyOpsAborted=TRUE ret=0x%x, at=%i with %s -> %s\n",retCode,where,pFrom,pTo);673 674 675 676 677 return 0; 670 if (pTempFrom) HeapFree(GetProcessHeap(), 0, pTempFrom); 671 672 if (nlpFileOp.fAnyOperationsAborted) { 673 lpFileOp->fAnyOperationsAborted=TRUE; 674 if (TempretCode > retCode) { 675 retCode = TempretCode; 676 } /* endif */ 677 } 678 if (lpFileOp->fAnyOperationsAborted==TRUE) { 679 if (FO_DELETE == (lpFileOp->wFunc & 15)) { 680 TRACE(__FUNCTION__" Setting AnyOpsAborted=TRUE level=%d ret=0x%x, at=%i with %s\n",level, retCode,where,pFrom); 681 } else { 682 TRACE(__FUNCTION__" Setting AnyOpsAborted=TRUE level=%d ret=0x%x, at=%i with %s -> %s\n",level, retCode,where,pFrom,pTo); 683 } 684 return retCode; 685 } /* endif */ 686 TRACE(__FUNCTION__" Setting AnyOpsAborted=FALSE\n"); 687 return 0; 678 688 679 689 #endif
Note:
See TracChangeset
for help on using the changeset viewer.