Changeset 1402 for trunk/dll/copyf.c
- Timestamp:
- Mar 14, 2009, 6:17:59 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/copyf.c
r1321 r1402 20 20 29 Feb 08 GKY Use xfree where appropriate 21 21 19 Jul 08 GKY Modify MakeTempName for use making temp directory names 22 08 Mar 09 GKY Removed variable aurguments from docopyf and unlinkf (not used) 22 23 23 24 ***********************************************************************/ … … 417 418 } 418 419 else 419 rc = docopyf(type,, "%s",); /* copy file */420 // docopyf changed this won't work rc = docopyf(type,, "%s",); /* copy file */ 420 421 DosError(FERR_DISABLEHARDERR); 421 422 } while (!rc && !DosFindNext()); … … 429 430 #endif 430 431 431 APIRET docopyf(INT type, CHAR * oldname, CHAR * newname, ...)432 APIRET docopyf(INT type, CHAR *oldname, CHAR *newname) 432 433 { 433 434 /* … … 440 441 */ 441 442 442 CHAR fullnewname[CCHMAXPATH + 1], longname[CCHMAXPATH], 443 shortname[CCHMAXPATH]; 443 CHAR longname[CCHMAXPATH], shortname[CCHMAXPATH]; 444 444 CHAR olddisk, newdisk, dir[CCHMAXPATH], *p, *pp; 445 445 APIRET ret = -1, rc; 446 446 FILESTATUS3L st, st2, dummy; 447 447 BOOL diskchange = FALSE, zaplong = FALSE; 448 va_list ap; 449 450 *fullnewname = *shortname = *dir = 0; 451 452 va_start(ap, newname); 453 vsprintf(fullnewname, newname, ap); 454 va_end(ap); 455 456 if (!oldname || !*oldname || !*fullnewname) /* bad string args */ 448 449 *shortname = *dir = 0; 450 451 if (!oldname || !*oldname || !*newname) /* bad string args */ 457 452 return (APIRET) - 1; 458 453 … … 461 456 return (APIRET) - 2; /* no source */ 462 457 463 AdjustWildcardName(oldname, fullnewname);458 AdjustWildcardName(oldname, newname); 464 459 MakeFullName(oldname); 465 MakeFullName( fullnewname);460 MakeFullName(newname); 466 461 olddisk = toupper(*oldname); /* source drive */ 467 newdisk = toupper(* fullnewname); /* destination drive */462 newdisk = toupper(*newname); /* destination drive */ 468 463 if (!(driveflags[toupper(*oldname) - 'A'] & DRIVE_NOLONGNAMES)) 469 464 *longname = 0; … … 478 473 /* If root name changed make sure longname EA goes away */ 479 474 p = RootName(oldname); 480 pp = RootName( fullnewname);475 pp = RootName(newname); 481 476 if (stricmp(p, pp)) { 482 477 zaplong = TRUE; … … 493 488 hobjsrc = WinQueryObject(oldname); 494 489 if (hobjsrc) { 495 strcpy(dir, fullnewname);490 strcpy(dir, newname); 496 491 p = strrchr(dir, '\\'); 497 492 if (p < dir + 3) … … 518 513 hobjsrc = WinQueryObject(oldname); 519 514 if (hobjsrc) { 520 strcpy(dir, fullnewname);515 strcpy(dir, newname); 521 516 p = strrchr(dir, '\\'); 522 517 if (p < dir + 3) … … 539 534 if (olddisk == newdisk) { /* same drive */ 540 535 /* make temporary copy in case move fails */ 541 if (IsFile( fullnewname) != -1 && stricmp(oldname, fullnewname)) {542 strcpy(dir, fullnewname);536 if (IsFile(newname) != -1 && stricmp(oldname, newname)) { 537 strcpy(dir, newname); 543 538 p = strrchr(dir, '\\'); 544 539 if (p) … … 546 541 strcat(dir, "\\"); 547 542 MakeTempName(dir, NULL, 0); 548 if (DosMove( fullnewname, dir))543 if (DosMove(newname, dir)) 549 544 *dir = 0; 550 545 } 551 546 DosError(FERR_DISABLEHARDERR); 552 ret = DosMove(oldname, fullnewname); /* move it */547 ret = DosMove(oldname, newname); /* move it */ 553 548 if (ret && *dir) { /* failed -- clean up */ 554 549 DosError(FERR_DISABLEHARDERR); 555 if (!DosMove(dir, fullnewname))550 if (!DosMove(dir, newname)) 556 551 Broadcast((HAB) 0, hwndMain, UM_UPDATERECORD, MPFROMP(dir), MPVOID); 557 552 } … … 580 575 else { /* different drives */ 581 576 DosError(FERR_DISABLEHARDERR); 582 ret = DosCopy(oldname, fullnewname, DCPY_EXISTING); /* <=-NOTE! */577 ret = DosCopy(oldname, newname, DCPY_EXISTING); /* <=-NOTE! */ 583 578 if (ret == ERROR_DISK_CHANGE) { 584 579 DosError(FERR_ENABLEHARDERR); 585 ret = DosCopy(oldname, fullnewname, DCPY_EXISTING);580 ret = DosCopy(oldname, newname, DCPY_EXISTING); 586 581 diskchange = TRUE; 587 582 } 588 583 if (ret == ERROR_INVALID_NAME || ret == ERROR_FILENAME_EXCED_RANGE) { 589 if (TruncName( fullnewname, shortname)) { /* make 8.3 filename */584 if (TruncName(newname, shortname)) { /* make 8.3 filename */ 590 585 DosError(FERR_DISABLEHARDERR); 591 586 ret = DosCopy(oldname, shortname, DCPY_EXISTING); 592 587 if (!ret) { /* success -- write longname ea */ 593 WriteLongName(shortname, fullnewname);594 strcpy( fullnewname, shortname);588 WriteLongName(shortname, newname); 589 strcpy(newname, shortname); 595 590 /* broadcast fixup msg to windows */ 596 591 Broadcast((HAB) 0, … … 603 598 CHAR fixname[CCHMAXPATH]; 604 599 605 strcpy(fixname, fullnewname);600 strcpy(fixname, newname); 606 601 p = strrchr(fixname, '\\'); 607 602 if (p) { … … 611 606 strcat(fixname, longname); 612 607 DosError(FERR_DISABLEHARDERR); 613 DosMove( fullnewname, fixname);614 strcpy( fullnewname, fixname);608 DosMove(newname, fixname); 609 strcpy(newname, fixname); 615 610 if (zaplong) 616 611 ZapLongName(fixname); … … 620 615 if (!ret) { /* double-check success */ 621 616 DosError(FERR_DISABLEHARDERR); 622 rc = DosQueryPathInfo( fullnewname,617 rc = DosQueryPathInfo(newname, 623 618 FIL_STANDARDL, &st2, sizeof(FILESTATUS3L)); 624 619 if (rc == ERROR_DISK_CHANGE) { 625 620 DosError(FERR_ENABLEHARDERR); 626 rc = DosQueryPathInfo( fullnewname,621 rc = DosQueryPathInfo(newname, 627 622 FIL_STANDARDL, &st2, sizeof(FILESTATUS3L)); 628 623 } … … 634 629 } 635 630 if (!(st2.attrFile & FILE_DIRECTORY)) /* erase file */ 636 unlinkf( "%s",oldname);631 unlinkf(oldname); 637 632 else { /* remove directory */ 638 633 wipeallf("%s\\*", oldname); … … 650 645 case COPY: 651 646 DosError(FERR_DISABLEHARDERR); 652 ret = DosCopy(oldname, fullnewname, DCPY_EXISTING); /* <=-NOTE! */647 ret = DosCopy(oldname, newname, DCPY_EXISTING); /* <=-NOTE! */ 653 648 if (ret == ERROR_DISK_CHANGE) { 654 649 DosError(FERR_ENABLEHARDERR); 655 ret = DosCopy(oldname, fullnewname, DCPY_EXISTING);650 ret = DosCopy(oldname, newname, DCPY_EXISTING); 656 651 diskchange = TRUE; 657 652 } 658 653 if (ret == ERROR_INVALID_NAME || ret == ERROR_FILENAME_EXCED_RANGE) { 659 if (TruncName( fullnewname, shortname)) {654 if (TruncName(newname, shortname)) { 660 655 DosError((diskchange) ? FERR_ENABLEHARDERR : FERR_DISABLEHARDERR); 661 656 ret = DosCopy(oldname, shortname, DCPY_EXISTING); 662 657 if (!ret) { 663 WriteLongName(shortname, fullnewname);664 strcpy( fullnewname, shortname);658 WriteLongName(shortname, newname); 659 strcpy(newname, shortname); 665 660 Broadcast((HAB) 0, 666 661 hwndMain, UM_UPDATERECORD, MPFROMP(shortname), MPVOID); … … 672 667 CHAR fixname[CCHMAXPATH]; 673 668 674 strcpy(fixname, fullnewname);669 strcpy(fixname, newname); 675 670 p = strrchr(fixname, '\\'); 676 671 if (p) { … … 680 675 strcat(fixname, longname); 681 676 DosError(FERR_DISABLEHARDERR); 682 DosMove( fullnewname, fixname);677 DosMove(newname, fixname); 683 678 if (zaplong) 684 679 ZapLongName(fixname); … … 901 896 #endif 902 897 903 INT unlinkf(CHAR * string, ...) 904 { 905 CHAR buffer[CCHMAXPATH]; 906 va_list ap; 907 908 va_start(ap, string); 909 vsprintf(buffer, string, ap); 910 va_end(ap); 911 912 if (!strstr(buffer, ArcTempRoot)) { 898 INT unlinkf(CHAR *string) 899 { 900 901 if (!strstr(string, ArcTempRoot)) { 913 902 DosError(FERR_DISABLEHARDERR); 914 if (DosDelete( buffer)) {915 make_deleteable( buffer);903 if (DosDelete(string)) { 904 make_deleteable(string); 916 905 DosError(FERR_DISABLEHARDERR); 917 return DosDelete( buffer);906 return DosDelete(string); 918 907 } 919 908 } 920 909 else { 921 910 DosError(FERR_DISABLEHARDERR); 922 if (DosForceDelete( buffer)) {923 make_deleteable( buffer);911 if (DosForceDelete(string)) { 912 make_deleteable(string); 924 913 DosError(FERR_DISABLEHARDERR); 925 return DosForceDelete( buffer);914 return DosForceDelete(string); 926 915 } 927 916 }
Note:
See TracChangeset
for help on using the changeset viewer.