Ignore:
Timestamp:
Sep 5, 2001, 3:19:02 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ole32/filemoniker.c

    r5602 r6648  
     1/* $Id: filemoniker.c,v 1.2 2001-09-05 13:17:09 bird Exp $ */
    12/***************************************************************************************
    2  *                            FileMonikers implementation
     3 *                        FileMonikers implementation
    34 *
    45 *               Copyright 1999  Noomen Hamza
     
    2627    ICOM_VTABLE(IMoniker)*  lpvtbl1;  /* VTable relative to the IMoniker interface.*/
    2728
    28     /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 
     29    /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
    2930     * two monikers are equal. That's whay IROTData interface is implemented by monikers.
    3031     */
     
    136137{
    137138    ICOM_THIS(FileMonikerImpl,iface);
    138  
     139
    139140  TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
    140141
    141142    /* Perform a sanity check on the parameters.*/
    142143    if ( (This==0) || (ppvObject==0) )
    143         return E_INVALIDARG;
    144  
     144    return E_INVALIDARG;
     145
    145146    /* Initialize the return parameter */
    146147  *ppvObject = 0;
     
    153154       )
    154155        *ppvObject = iface;
    155    
     156
    156157    else if (IsEqualIID(&IID_IROTData, riid))
    157158        *ppvObject = (IROTData*)&(This->lpvtbl2);
     
    160161    if ((*ppvObject)==0)
    161162        return E_NOINTERFACE;
    162  
     163
    163164    /* Query Interface always increases the reference count by one when it is successful */
    164165  FileMonikerImpl_AddRef(iface);
     
    212213
    213214    *pClassID = CLSID_FileMoniker;
    214        
     215
    215216    return S_OK;
    216217}
     
    252253    if (bread!=sizeof(WORD) || wbuffer!=0)
    253254        return E_FAIL;
    254    
     255
    255256    /* read filePath string length (plus one) */
    256257    res=IStream_Read(pStm,&length,sizeof(DWORD),&bread);
     
    268269    if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF)
    269270        return E_FAIL;
    270        
     271
    271272    length--;
    272        
     273
    273274    for(i=0;i<10;i++){
    274275        res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
     
    276277            return E_FAIL;
    277278    }
    278    
     279
    279280    if (length>8)
    280281        length=0;
    281        
     282
    282283    doubleLenHex=doubleLenDec=2*length;
    283284    if (length > 5)
     
    290291    if (length==0)
    291292        return res;
    292        
     293
    293294    res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
    294295    if (bread!=sizeof(DWORD) || dwbuffer!=doubleLenHex)
     
    311312
    312313    HeapFree(GetProcessHeap(),0,filePathA);
    313    
     314
    314315    return res;
    315316}
     
    324325    /* this function saves data of this object. In the begining I thougth that I have just to write
    325326     * the filePath string on Stream. But, when I tested this function whith windows programs samples !
    326      * I noted that it was not the case. So I analysed data written by this function on Windows system and 
     327     * I noted that it was not the case. So I analysed data written by this function on Windows system and
    327328     * what did this function do exactly ! but I have no idear a bout its logic !
    328329     * I guessed data who must be written on stream wich is:
     
    333334     */
    334335
    335     ICOM_THIS(FileMonikerImpl,iface);       
     336    ICOM_THIS(FileMonikerImpl,iface);
    336337
    337338    HRESULT res;
     
    368369    /* write a DWORD set to 0xDEADFFFF: constant */
    369370    res=IStream_Write(pStm,&constant1,sizeof(DWORD),NULL);
    370        
     371
    371372    len--;
    372373    /* write 10 times a DWORD set to 0 : constants */
    373374    for(i=0;i<10;i++)
    374375        res=IStream_Write(pStm,&zero,sizeof(WORD),NULL);
    375        
     376
    376377    if (len>8)
    377378        len=0;
    378        
     379
    379380    doubleLenHex=doubleLenDec=2*len;
    380381    if (len > 5)
     
    415416
    416417    /* for more details see FileMonikerImpl_Save coments */
    417    
     418
    418419    sizeMAx =  sizeof(WORD) +           /* first WORD is 0 */
    419420               sizeof(DWORD)+           /* length of filePath including "\0" in the end of the string */
     
    425426    if (len==0 || len > 8)
    426427        return S_OK;
    427    
     428
    428429    sizeMAx += sizeof(DWORD)+           /* size of the unicode filePath: "\0" not included */
    429430               sizeof(WORD)+            /* constant : 0x3 */
    430431               len*sizeof(WCHAR);       /* unicde filePath string */
    431    
     432
    432433    pcbSize->s.LowPart=sizeMAx;
    433434    pcbSize->s.HighPart=0;
     
    447448    WCHAR bkSlash[]={'\\',0};
    448449    BYTE addBkSlash;
    449    
     450
    450451    TRACE("(%p,%p)\n",This,lpszPathName);
    451452
     
    492493
    493494        *This->filePathName=0;
    494    
     495
    495496        for(i=0;tabStr[i]!=NULL;i++)
    496497            strcatW(This->filePathName,tabStr[i]);
    497    
     498
    498499        if (addBkSlash)
    499500            strcatW(This->filePathName,bkSlash);
     
    538539    IClassFactory *pcf=0;
    539540    IClassActivator *pca=0;
    540    
    541     ICOM_THIS(FileMonikerImpl,iface);   
     541
     542    ICOM_THIS(FileMonikerImpl,iface);
    542543
    543544    *ppvResult=0;
     
    546547
    547548    if(pmkToLeft==NULL){
    548        
     549
    549550        res=IBindCtx_GetRunningObjectTable(pbc,&prot);
    550551
     
    578579
    579580            res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca);
    580        
     581
    581582            if (res==E_NOINTERFACE)
    582583                return MK_E_INTERMEDIATEINTERFACENOTSUPPORTED;
     
    597598
    598599            FIXME("()");
    599            
     600
    600601            /*res=GetClassFile(This->filePathName,&clsID);
    601602
     
    633634    if (pcf!=NULL)
    634635        IClassFactory_Release(pcf);
    635    
     636
    636637    return res;
    637638}
     
    736737
    737738    if (pmkRight==NULL)
    738         return E_INVALIDARG;
     739    return E_INVALIDARG;
    739740
    740741    *ppmkComposite=0;
    741    
     742
    742743    IMoniker_IsSystemMoniker(pmkRight,&mkSys);
    743744
     
    768769        /* the length of the composed path string  is raised by the sum of the two paths lengths  */
    769770        newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
    770        
    771           if (newStr==NULL)
    772                 return E_OUTOFMEMORY;
     771
     772      if (newStr==NULL)
     773        return E_OUTOFMEMORY;
    773774
    774775        /* new path is the concatenation of the rest of str1 and str2 */
     
    778779        if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0)
    779780            strcatW(newStr,bkSlash);
    780            
     781
    781782        for(j=i;j<=lastIdx2;j++)
    782783            strcatW(newStr,strDec2[j]);
    783        
     784
    784785        /* create a new moniker with the new string */
    785786        res=CreateFileMoniker(newStr,ppmkComposite);
     
    857858
    858859    IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath);
    859    
     860
    860861    if (lstrcmpiW(filePath,
    861862                  This->filePathName)!=0)
    862863
    863864        return S_FALSE;
    864    
     865
    865866    return S_OK;
    866867}
     
    879880    if (pdwHash==NULL)
    880881        return E_POINTER;
    881    
     882
    882883    val =  This->filePathName;
    883884    len = lstrlenW(val);
     
    886887        for (i = len ; i > 0; i--) {
    887888            h = (h * 37) + val[off++];
    888         }
     889    }
    889890    } else {
    890891        /* only sample some characters */
    891         skip = len / 8;
    892         for (i = len ; i > 0; i -= skip, off += skip) {
     892    skip = len / 8;
     893    for (i = len ; i > 0; i -= skip, off += skip) {
    893894            h = (h * 39) + val[off];
    894         }
     895    }
    895896}
    896897
     
    963964        if (!GetFileAttributesExW(This->filePathName,GetFileExInfoStandard,&info))
    964965            return MK_E_NOOBJECT;
    965        
     966
    966967        *pFileTime=info.ftLastWriteTime;
    967968}
     
    998999    if (pmkOther==NULL)
    9991000        return E_INVALIDARG;
    1000    
     1001
    10011002    *ppmkPrefix=0;
    1002    
     1003
    10031004    /* check if we have the same type of moniker */
    10041005    IMoniker_IsSystemMoniker(pmkOther,&mkSys);
     
    10221023
    10231024        *commonPath=0;
    1024        
     1025
    10251026        for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) &&
    10261027                         (stringTable2[sameIdx]!=NULL) &&
     
    10411042        if (machimeNameCase && *stringTable1[sameIdx-1]=='\\')
    10421043            sameIdx--;
    1043        
     1044
    10441045        if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) )
    10451046            return MK_E_NOPREFIX;
     
    10471048        for(i=0;i<sameIdx;i++)
    10481049            strcatW(commonPath,stringTable1[i]);
    1049        
     1050
    10501051        for(i=0;i<nb1;i++)
    10511052            CoTaskMemFree(stringTable1[i]);
     
    10591060
    10601061        HeapFree(GetProcessHeap(),0,commonPath);
    1061        
     1062
    10621063        return CreateFileMoniker(commonPath,ppmkPrefix);
    10631064    }
     
    10791080
    10801081    strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR));
    1081    
     1082
    10821083    if (strgtable==NULL)
    1083         return E_OUTOFMEMORY;
    1084    
     1084    return E_OUTOFMEMORY;
     1085
    10851086    while(str[i]!=0){
    10861087
     
    10901091
    10911092            if (strgtable[tabIndex]==NULL)
    1092                 return E_OUTOFMEMORY;
     1093            return E_OUTOFMEMORY;
    10931094
    10941095            strcpyW(strgtable[tabIndex++],bSlash);
     
    11131114    }
    11141115    strgtable[tabIndex]=NULL;
    1115    
     1116
    11161117    *stringTable=strgtable;
    1117    
     1118
    11181119    return tabIndex;
    11191120}
     
    11291130    DWORD len1=0,len2=0,sameIdx=0,j=0;
    11301131    WCHAR back[] ={'.','.','\\',0};
    1131    
     1132
    11321133    TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
    11331134
     
    11371138    if (pmOther==NULL)
    11381139        return E_INVALIDARG;
    1139    
     1140
    11401141    res=CreateBindCtx(0,&bind);
    11411142    if (FAILED(res))
    1142         return res;
     1143    return res;
    11431144
    11441145    res=IMoniker_GetDisplayName(iface,bind,NULL,&str1);
    11451146    if (FAILED(res))
    1146         return res;
     1147    return res;
    11471148    res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2);
    11481149    if (FAILED(res))
    1149         return res;
     1150    return res;
    11501151
    11511152    len1=FileMonikerImpl_DecomposePath(str1,&tabStr1);
     
    11531154
    11541155    if (FAILED(len1) || FAILED(len2))
    1155         return E_OUTOFMEMORY;
    1156        
     1156    return E_OUTOFMEMORY;
     1157
    11571158    /* count the number of similar items from the begin of the two paths */
    11581159    for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) &&
    1159                    (tabStr2[sameIdx]!=NULL) &&
     1160           (tabStr2[sameIdx]!=NULL) &&
    11601161               (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++);
    11611162
     
    11751176    for(j=sameIdx;tabStr2[j]!=NULL;j++)
    11761177        strcatW(relPath,tabStr2[j]);
    1177    
     1178
    11781179    res=CreateFileMoniker(relPath,ppmkRelPath);
    1179    
     1180
    11801181    for(j=0; tabStr1[j]!=NULL;j++)
    11811182        CoTaskMemFree(tabStr1[j]);
     
    12191220
    12201221    strcpyW(*ppszDisplayName,This->filePathName);
    1221    
     1222
    12221223    return S_OK;
    12231224}
     
    12461247    if (!pwdMksys)
    12471248        return E_POINTER;
    1248    
     1249
    12491250    (*pwdMksys)=MKSYS_FILEMONIKER;
    12501251
     
    12831284{
    12841285    ICOM_THIS_From_IROTData(IMoniker, iface);
    1285    
     1286
    12861287    TRACE("(%p)\n",This);
    12871288
     
    13271328    if(lpszPathName==NULL)
    13281329        return MK_E_SYNTAX;
    1329            
     1330
    13301331    *ppmk=0;
    1331        
     1332
    13321333    newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
    13331334
     
    13381339
    13391340    if (SUCCEEDED(hr))
    1340         hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&riid,(void**)ppmk);
     1341    hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&riid,(void**)ppmk);
    13411342    else
    13421343        HeapFree(GetProcessHeap(),0,newFileMoniker);
Note: See TracChangeset for help on using the changeset viewer.