Changeset 5654


Ignore:
Timestamp:
May 4, 2001, 7:01:29 PM (24 years ago)
Author:
sandervl
Message:

DT: SHFileOperation update (FO_MOVE)

File:
1 edited

Legend:

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

    r5636 r5654  
    107107        PathAddBackslashA(szTemp);
    108108        strcat(szTemp, "*.*");
    109        
     109
    110110        if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FOLDER, pszDir))
    111111          return FALSE;
     
    174174 * ANSI.  Is this Unicode on NT?
    175175 *
    176  */ 
     176 */
    177177
    178178BOOL WINAPI Win32DeleteFile(LPSTR fName)
     
    198198        DWORD FromAttr;
    199199        DWORD ToAttr;
    200         LPSTR pTempFrom;
    201         LPSTR pTempTo = NULL;
     200        LPSTR pTempFrom = NULL;
     201        LPSTR pTempTo;
    202202        LPSTR pFromFile;
    203203        LPSTR pToFile;
     
    228228        LPSTR pTempTo;
    229229#endif
    230        
     230
    231231        switch(lpFileOp->wFunc) {
    232232        case FO_COPY:
    233233                TRACE("File Copy:\n");
    234234#ifdef __WIN32OS2__
    235             pTempTo = HeapAlloc(GetProcessHeap(), 0, 3 * MAX_PATH+6);
    236             pTempFrom = &pTempTo[2*MAX_PATH+2];
     235            pTempFrom = HeapAlloc(GetProcessHeap(), 0, 3 * MAX_PATH+6);
     236            pTempTo = &pTempFrom[MAX_PATH+4];
    237237/*
    238238 * FOF_MULTIDESTFILES, FOF_NOCONFIRMATION, FOF_FILESONLY                                are     implemented
     
    267267                if(!pTo[0]) {
    268268                        nlpFileOp.fAnyOperationsAborted=TRUE;
    269                         where = 13;
     269                        where = 213;
    270270                        break;
    271271                }
     
    275275// fix for more then one source for one target
    276276                pToFile[0] = '\0';
     277                nlpFileOp.pTo = pTo;
    277278
    278279                lenFrom=strlen(pFrom);
     
    311312                        (!withFileName && !ToSingle) ) {
    312313                        nlpFileOp.fAnyOperationsAborted=TRUE;
    313                         where = 1;
     314                        where = 201;
    314315                        break;
    315316                    }
     
    329330                    lenTempFrom = strlen(pTempFrom);
    330331                    pFromFile=&pTempFrom[lenTempFrom];
    331                        
     332
    332333                    if (FromAttr == -1 ||
    333334                       ((lenTempFrom==lenFrom) && !PathIsRootA(pFrom)) ||
     
    336337                        retCode=0x402;
    337338                        nlpFileOp.fAnyOperationsAborted=TRUE;
    338                         where = 2;
     339                        where = 202;
    339340                        break;
    340341                    }
     
    345346                        nlpFileOp.fAnyOperationsAborted=TRUE;
    346347                        retCode=0x79;
    347                         where = 3;
     348                        where = 203;
    348349                        break;
    349350                    }
     
    369370                        TempretCode = SHFileOperationA (&nlpFileOp);
    370371
    371                         if (nlpFileOp.fAnyOperationsAborted) {where = 4;break;}
     372                        if (nlpFileOp.fAnyOperationsAborted) {where = 204;break;}
    372373
    373374                    } while(FindNextFileA(hFind, &wfd));
    374375
    375376                    FindClose(hFind);
    376                     if (nlpFileOp.fAnyOperationsAborted) {where = 5;break;}
     377                    if (nlpFileOp.fAnyOperationsAborted) {where = 205;break;}
    377378                    continue;
    378379                }
    379 
    380380
    381381                lenTempTo = strlen(pTempTo);
     
    387387                    nlpFileOp.fAnyOperationsAborted=TRUE;
    388388                    retCode=0x402;
    389                     where = 6;
     389                    where = 206;
    390390                    break;
    391391                } /* endif */
     
    408408                if (!pFromFile) {
    409409                    nlpFileOp.fAnyOperationsAborted=TRUE;
    410                     where = 7;
     410                    where = 207;
    411411                    break;
    412412                } /* endif */
     
    420420                ToAttr = GetFileAttributesA(pTempTo);
    421421
    422 
    423422                if (FromAttr == -1) {
    424423                    FIXME(__FUNCTION__" FO_COPY with Source %s not implementiert ,stub\n",pTempFrom);
    425424                    nlpFileOp.fAnyOperationsAborted=TRUE;
    426                     where = 8;
     425                    where = 208;
    427426                    break;
    428427                }
     
    436435                            nlpFileOp.fAnyOperationsAborted=TRUE;
    437436                            retCode=0x10003;
    438                             where = 9;
     437                            where = 209;
    439438                            break;
    440439                        }
     
    459458                        FIXME(__FUNCTION__" FO_COPY unexpected with %s -> %s ? ,stub\n",pTempFrom,pTo);
    460459                        nlpFileOp.fAnyOperationsAborted=TRUE;
    461                         where = 10;
     460                        where = 210;
    462461                        retCode=0x77;
    463462                        break;
     
    469468                if (!(ToAttr == -1) && (ToAttr & FILE_ATTRIBUTE_DIRECTORY)) {
    470469                    nlpFileOp.fAnyOperationsAborted=TRUE;
    471                     where = 11;
     470                    where = 211;
    472471                    break;
    473472                }
     
    475474                    nlpFileOp.fAnyOperationsAborted=TRUE;
    476475                    retCode = 0x71;
    477                     where = 12;
     476                    where = 212;
    478477                    break;
    479478                }
     
    488487
    489488                nlpFileOp.fAnyOperationsAborted=TRUE;
     489                where = 215;
    490490            }
    491 
    492             if (pTempTo) HeapFree(GetProcessHeap(), 0, pTempTo);
    493 
    494             if (nlpFileOp.fAnyOperationsAborted) {
    495                 lpFileOp->fAnyOperationsAborted=TRUE;
    496                 if (TempretCode > retCode) {
    497                     retCode = TempretCode;
    498                 } /* endif */
    499             }
    500             if (lpFileOp->fAnyOperationsAborted==TRUE) {
    501                 TRACE(__FUNCTION__" Setting AnyOpsAborted=TRUE ret=0x%x, at=%i with %s -> %s\n",retCode,where,pFrom,pTo);
    502                 return retCode;
    503             } /* endif */
    504 
    505             TRACE(__FUNCTION__" Setting AnyOpsAborted=FALSE\n");
    506             return 0;
     491            break;
    507492#else
    508493                while(1) {
     
    532517        case FO_DELETE:
    533518                TRACE("File Delete:\n");
     519#ifdef __WIN32OS2__
     520            while((pFrom+=lenFrom+1)[0] && !nlpFileOp.fAnyOperationsAborted) {
     521                lenFrom=strlen(pFrom);
     522                FromAttr = GetFileAttributesA(pFrom);
     523                if (!(FromAttr & FILE_ATTRIBUTE_DIRECTORY)) {
     524                    TRACE("   File='%s'\n", pFrom);
     525                    if (DeleteFileA(pFrom)) continue;
     526                    nlpFileOp.fAnyOperationsAborted=TRUE;
     527//                  retCode = 0x71;
     528                    where = 301;
     529                    break;
     530                }
     531                if (!(pTempFrom)) pTempFrom = HeapAlloc(GetProcessHeap(), 0, MAX_PATH+2);
     532                strcpy(pTempFrom,pFrom);
     533                PathRemoveBackslashA(pTempFrom);
     534                FromAttr = GetFileAttributesA(pTempFrom);
     535                if (!(FromAttr & FILE_ATTRIBUTE_DIRECTORY) ) {
     536                    nlpFileOp.fAnyOperationsAborted=TRUE;
     537//                  retCode = 0x71;
     538                    where = 302;
     539                    break;
     540                }
     541// is Source an existing directory\*.* ?
     542                if (FromAttr == -1) {
     543                    PathRemoveFileSpecA(pTempFrom);
     544                    FromAttr = GetFileAttributesA(pTempFrom);
     545                }
     546
     547                PathAddBackslashA(pTempFrom);
     548                lenTempFrom = strlen(pTempFrom);
     549                pFromFile=&pTempFrom[lenTempFrom];
     550
     551                if (FromAttr == -1 ||
     552                   ((lenTempFrom==lenFrom) && !PathIsRootA(pFrom)) ||
     553                  !(FromAttr & FILE_ATTRIBUTE_DIRECTORY) ||
     554                  !(('\0'==pFrom[lenTempFrom]) || (0==strcmp(&pFrom[lenTempFrom],"*.*"))) ) {
     555                    retCode=0x402;
     556                    nlpFileOp.fAnyOperationsAborted=TRUE;
     557                    where = 303;
     558                    break;
     559                }
     560                strcpy(pFromFile, "*.*");
     561                lenTempFrom = strlen(pTempFrom);
     562                if (lenFrom < lenTempFrom) {
     563// Source is without \*.*
     564                    pTempFrom[lenTempFrom+1]='\0';
     565                    nlpFileOp.pFrom = pTempFrom;
     566
     567                    TRACE(__FUNCTION__"   Entering Directory '%s'\n", nlpFileOp.pFrom);
     568                    TempretCode = SHFileOperationA (&nlpFileOp);
     569
     570                    if (nlpFileOp.fAnyOperationsAborted) {break;}
     571// Call SHELL_DeleteDirectoryA ?
     572                    if (RemoveDirectoryA(pFrom)) continue;
     573                    nlpFileOp.fAnyOperationsAborted=TRUE;
     574                    where = 304;
     575                    break;
     576                }
     577                hFind = FindFirstFileA(pTempFrom, &wfd);
     578                if (INVALID_HANDLE_VALUE == hFind) {
     579                    nlpFileOp.fAnyOperationsAborted=TRUE;
     580                    retCode=0x79;
     581                    where = 303;
     582                    break;
     583                }
     584
     585                nlpFileOp.pFrom  = pTempFrom;
     586// single copy never with FOF_MULTIDESTFILES, I can use lpFileOp->pTo as nlpFileOp.pTo,
     587// I need no different targetarea for the name
     588                nlpFileOp.fFlags = (nlpFileOp.fFlags & (-1 - (FOF_MULTIDESTFILES)));
     589
     590                TRACE(__FUNCTION__"   Delete in Subdir %s'\n", nlpFileOp.pFrom);
     591
     592                do {
     593                    TRACE(__FUNCTION__"   find '%s'\n", wfd.cFileName);
     594                    if (0==strcmp(wfd.cFileName,".")) continue;
     595                    if (0==strcmp(wfd.cFileName,"..")) continue;
     596                    if ((nlpFileOp.fFlags & FOF_FILESONLY) && (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)) {
     597                        continue;
     598                        } /* endif */
     599
     600                    strcpy(pFromFile,wfd.cFileName);
     601                    pTempFrom[strlen(pTempFrom)+1]='\0';
     602
     603                    TempretCode = SHFileOperationA (&nlpFileOp);
     604
     605                    if (nlpFileOp.fAnyOperationsAborted) {where = 304;break;}
     606
     607                } while(FindNextFileA(hFind, &wfd));
     608
     609                FindClose(hFind);
     610                if (nlpFileOp.fAnyOperationsAborted) {where = 305;break;}
     611                continue;
     612            }
     613            break;
     614        case FO_MOVE:
     615                TRACE("File\\Tree Move: simply (Copy/Delete)\n");
     616        nlpFileOp.wFunc = FO_COPY;
     617// not delete at error from copy
     618        TempretCode = SHFileOperationA (&nlpFileOp);
     619
     620        if (nlpFileOp.fAnyOperationsAborted) {
     621            if (TempretCode == 0x75) {
     622// not all, the most
     623                TempretCode = 0xD7;
     624                retCode = 0xD7;
     625            } /* endif */
     626            break;
     627        }
     628
     629        nlpFileOp.wFunc = FO_DELETE;
     630
     631        TempretCode = SHFileOperationA (&nlpFileOp);
     632
     633        case 0:
     634            break;
     635#else
    534636                while(1) {
    535637                        if(!pFrom[0]) break;
     
    541643                lpFileOp->fAnyOperationsAborted=FALSE;
    542644                return 0;
     645#endif
    543646
    544647        default:
     648#ifdef __WIN32OS2__
     649                FIXME(__FUNCTION__" Unhandled shell file operation %d stub\n", lpFileOp->wFunc);
     650#else
    545651                FIXME("Unhandled shell file operation %d\n", lpFileOp->wFunc);
     652#endif
     653           return 1;
    546654        }
    547655
    548         return 1;
     656#ifdef __WIN32OS2__
     657    if (pTempFrom) HeapFree(GetProcessHeap(), 0, pTempFrom);
     658
     659    if (nlpFileOp.fAnyOperationsAborted) {
     660        lpFileOp->fAnyOperationsAborted=TRUE;
     661        if (TempretCode > retCode) {
     662            retCode = TempretCode;
     663        } /* endif */
     664    }
     665    if (lpFileOp->fAnyOperationsAborted==TRUE) {
     666        if (FO_DELETE == lpFileOp->wFunc) {
     667            TRACE(__FUNCTION__" Setting AnyOpsAborted=TRUE ret=0x%x, at=%i with %s\n",retCode,where,pFrom);
     668        } else {
     669            TRACE(__FUNCTION__" Setting AnyOpsAborted=TRUE ret=0x%x, at=%i with %s -> %s\n",retCode,where,pFrom,pTo);
     670        }
     671        return retCode;
     672    } /* endif */
     673    TRACE(__FUNCTION__" Setting AnyOpsAborted=FALSE\n");
     674    return 0;       
     675
     676#endif
    549677}
    550678
     
    557685DWORD WINAPI SHFileOperationW (LPSHFILEOPSTRUCTW lpFileOp)   
    558686{
     687#ifdef __WIN32OS2__
     688        FIXME(__FUNCTION__"(%p) ,stub\n", lpFileOp);
     689#else
    559690        FIXME("(%p):stub.\n", lpFileOp);
     691#endif
    560692        return 1;
    561693}
     
    577709 */
    578710HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v)
     711#ifdef __WIN32OS2__
     712{       FIXME(__FUNCTION__"(%p, %p) ,stub\n",u,v);
     713#else
    579714{       FIXME("%p %p stub\n",u,v);
     715#endif
    580716        return 0;
    581717}
     
    586722 */
    587723HRESULT WINAPI SheChangeDirW(LPWSTR u)
     724#ifdef __WIN32OS2__
     725{       FIXME(__FUNCTION__"(%s),stub\n",debugstr_w(u));
     726#else
    588727{       FIXME("(%s),stub\n",debugstr_w(u));
     728#endif
    589729        return 0;
    590730}
Note: See TracChangeset for help on using the changeset viewer.