Changeset 6648 for trunk/src/ole32/filemoniker.c
- Timestamp:
- Sep 5, 2001, 3:19:02 PM (24 years ago)
- 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 $ */ 1 2 /*************************************************************************************** 2 * 3 * FileMonikers implementation 3 4 * 4 5 * Copyright 1999 Noomen Hamza … … 26 27 ICOM_VTABLE(IMoniker)* lpvtbl1; /* VTable relative to the IMoniker interface.*/ 27 28 28 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 29 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether 29 30 * two monikers are equal. That's whay IROTData interface is implemented by monikers. 30 31 */ … … 136 137 { 137 138 ICOM_THIS(FileMonikerImpl,iface); 138 139 139 140 TRACE("(%p,%p,%p)\n",This,riid,ppvObject); 140 141 141 142 /* Perform a sanity check on the parameters.*/ 142 143 if ( (This==0) || (ppvObject==0) ) 143 144 144 return E_INVALIDARG; 145 145 146 /* Initialize the return parameter */ 146 147 *ppvObject = 0; … … 153 154 ) 154 155 *ppvObject = iface; 155 156 156 157 else if (IsEqualIID(&IID_IROTData, riid)) 157 158 *ppvObject = (IROTData*)&(This->lpvtbl2); … … 160 161 if ((*ppvObject)==0) 161 162 return E_NOINTERFACE; 162 163 163 164 /* Query Interface always increases the reference count by one when it is successful */ 164 165 FileMonikerImpl_AddRef(iface); … … 212 213 213 214 *pClassID = CLSID_FileMoniker; 214 215 215 216 return S_OK; 216 217 } … … 252 253 if (bread!=sizeof(WORD) || wbuffer!=0) 253 254 return E_FAIL; 254 255 255 256 /* read filePath string length (plus one) */ 256 257 res=IStream_Read(pStm,&length,sizeof(DWORD),&bread); … … 268 269 if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF) 269 270 return E_FAIL; 270 271 271 272 length--; 272 273 273 274 for(i=0;i<10;i++){ 274 275 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread); … … 276 277 return E_FAIL; 277 278 } 278 279 279 280 if (length>8) 280 281 length=0; 281 282 282 283 doubleLenHex=doubleLenDec=2*length; 283 284 if (length > 5) … … 290 291 if (length==0) 291 292 return res; 292 293 293 294 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread); 294 295 if (bread!=sizeof(DWORD) || dwbuffer!=doubleLenHex) … … 311 312 312 313 HeapFree(GetProcessHeap(),0,filePathA); 313 314 314 315 return res; 315 316 } … … 324 325 /* this function saves data of this object. In the begining I thougth that I have just to write 325 326 * 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 327 328 * what did this function do exactly ! but I have no idear a bout its logic ! 328 329 * I guessed data who must be written on stream wich is: … … 333 334 */ 334 335 335 ICOM_THIS(FileMonikerImpl,iface); 336 ICOM_THIS(FileMonikerImpl,iface); 336 337 337 338 HRESULT res; … … 368 369 /* write a DWORD set to 0xDEADFFFF: constant */ 369 370 res=IStream_Write(pStm,&constant1,sizeof(DWORD),NULL); 370 371 371 372 len--; 372 373 /* write 10 times a DWORD set to 0 : constants */ 373 374 for(i=0;i<10;i++) 374 375 res=IStream_Write(pStm,&zero,sizeof(WORD),NULL); 375 376 376 377 if (len>8) 377 378 len=0; 378 379 379 380 doubleLenHex=doubleLenDec=2*len; 380 381 if (len > 5) … … 415 416 416 417 /* for more details see FileMonikerImpl_Save coments */ 417 418 418 419 sizeMAx = sizeof(WORD) + /* first WORD is 0 */ 419 420 sizeof(DWORD)+ /* length of filePath including "\0" in the end of the string */ … … 425 426 if (len==0 || len > 8) 426 427 return S_OK; 427 428 428 429 sizeMAx += sizeof(DWORD)+ /* size of the unicode filePath: "\0" not included */ 429 430 sizeof(WORD)+ /* constant : 0x3 */ 430 431 len*sizeof(WCHAR); /* unicde filePath string */ 431 432 432 433 pcbSize->s.LowPart=sizeMAx; 433 434 pcbSize->s.HighPart=0; … … 447 448 WCHAR bkSlash[]={'\\',0}; 448 449 BYTE addBkSlash; 449 450 450 451 TRACE("(%p,%p)\n",This,lpszPathName); 451 452 … … 492 493 493 494 *This->filePathName=0; 494 495 495 496 for(i=0;tabStr[i]!=NULL;i++) 496 497 strcatW(This->filePathName,tabStr[i]); 497 498 498 499 if (addBkSlash) 499 500 strcatW(This->filePathName,bkSlash); … … 538 539 IClassFactory *pcf=0; 539 540 IClassActivator *pca=0; 540 541 ICOM_THIS(FileMonikerImpl,iface); 541 542 ICOM_THIS(FileMonikerImpl,iface); 542 543 543 544 *ppvResult=0; … … 546 547 547 548 if(pmkToLeft==NULL){ 548 549 549 550 res=IBindCtx_GetRunningObjectTable(pbc,&prot); 550 551 … … 578 579 579 580 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca); 580 581 581 582 if (res==E_NOINTERFACE) 582 583 return MK_E_INTERMEDIATEINTERFACENOTSUPPORTED; … … 597 598 598 599 FIXME("()"); 599 600 600 601 /*res=GetClassFile(This->filePathName,&clsID); 601 602 … … 633 634 if (pcf!=NULL) 634 635 IClassFactory_Release(pcf); 635 636 636 637 return res; 637 638 } … … 736 737 737 738 if (pmkRight==NULL) 738 739 return E_INVALIDARG; 739 740 740 741 *ppmkComposite=0; 741 742 742 743 IMoniker_IsSystemMoniker(pmkRight,&mkSys); 743 744 … … 768 769 /* the length of the composed path string is raised by the sum of the two paths lengths */ 769 770 newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1)); 770 771 772 771 772 if (newStr==NULL) 773 return E_OUTOFMEMORY; 773 774 774 775 /* new path is the concatenation of the rest of str1 and str2 */ … … 778 779 if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0) 779 780 strcatW(newStr,bkSlash); 780 781 781 782 for(j=i;j<=lastIdx2;j++) 782 783 strcatW(newStr,strDec2[j]); 783 784 784 785 /* create a new moniker with the new string */ 785 786 res=CreateFileMoniker(newStr,ppmkComposite); … … 857 858 858 859 IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath); 859 860 860 861 if (lstrcmpiW(filePath, 861 862 This->filePathName)!=0) 862 863 863 864 return S_FALSE; 864 865 865 866 return S_OK; 866 867 } … … 879 880 if (pdwHash==NULL) 880 881 return E_POINTER; 881 882 882 883 val = This->filePathName; 883 884 len = lstrlenW(val); … … 886 887 for (i = len ; i > 0; i--) { 887 888 h = (h * 37) + val[off++]; 888 889 } 889 890 } else { 890 891 /* only sample some characters */ 891 892 892 skip = len / 8; 893 for (i = len ; i > 0; i -= skip, off += skip) { 893 894 h = (h * 39) + val[off]; 894 895 } 895 896 } 896 897 … … 963 964 if (!GetFileAttributesExW(This->filePathName,GetFileExInfoStandard,&info)) 964 965 return MK_E_NOOBJECT; 965 966 966 967 *pFileTime=info.ftLastWriteTime; 967 968 } … … 998 999 if (pmkOther==NULL) 999 1000 return E_INVALIDARG; 1000 1001 1001 1002 *ppmkPrefix=0; 1002 1003 1003 1004 /* check if we have the same type of moniker */ 1004 1005 IMoniker_IsSystemMoniker(pmkOther,&mkSys); … … 1022 1023 1023 1024 *commonPath=0; 1024 1025 1025 1026 for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) && 1026 1027 (stringTable2[sameIdx]!=NULL) && … … 1041 1042 if (machimeNameCase && *stringTable1[sameIdx-1]=='\\') 1042 1043 sameIdx--; 1043 1044 1044 1045 if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) ) 1045 1046 return MK_E_NOPREFIX; … … 1047 1048 for(i=0;i<sameIdx;i++) 1048 1049 strcatW(commonPath,stringTable1[i]); 1049 1050 1050 1051 for(i=0;i<nb1;i++) 1051 1052 CoTaskMemFree(stringTable1[i]); … … 1059 1060 1060 1061 HeapFree(GetProcessHeap(),0,commonPath); 1061 1062 1062 1063 return CreateFileMoniker(commonPath,ppmkPrefix); 1063 1064 } … … 1079 1080 1080 1081 strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR)); 1081 1082 1082 1083 if (strgtable==NULL) 1083 1084 1084 return E_OUTOFMEMORY; 1085 1085 1086 while(str[i]!=0){ 1086 1087 … … 1090 1091 1091 1092 if (strgtable[tabIndex]==NULL) 1092 1093 return E_OUTOFMEMORY; 1093 1094 1094 1095 strcpyW(strgtable[tabIndex++],bSlash); … … 1113 1114 } 1114 1115 strgtable[tabIndex]=NULL; 1115 1116 1116 1117 *stringTable=strgtable; 1117 1118 1118 1119 return tabIndex; 1119 1120 } … … 1129 1130 DWORD len1=0,len2=0,sameIdx=0,j=0; 1130 1131 WCHAR back[] ={'.','.','\\',0}; 1131 1132 1132 1133 TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath); 1133 1134 … … 1137 1138 if (pmOther==NULL) 1138 1139 return E_INVALIDARG; 1139 1140 1140 1141 res=CreateBindCtx(0,&bind); 1141 1142 if (FAILED(res)) 1142 1143 return res; 1143 1144 1144 1145 res=IMoniker_GetDisplayName(iface,bind,NULL,&str1); 1145 1146 if (FAILED(res)) 1146 1147 return res; 1147 1148 res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2); 1148 1149 if (FAILED(res)) 1149 1150 return res; 1150 1151 1151 1152 len1=FileMonikerImpl_DecomposePath(str1,&tabStr1); … … 1153 1154 1154 1155 if (FAILED(len1) || FAILED(len2)) 1155 1156 1156 return E_OUTOFMEMORY; 1157 1157 1158 /* count the number of similar items from the begin of the two paths */ 1158 1159 for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) && 1159 1160 (tabStr2[sameIdx]!=NULL) && 1160 1161 (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++); 1161 1162 … … 1175 1176 for(j=sameIdx;tabStr2[j]!=NULL;j++) 1176 1177 strcatW(relPath,tabStr2[j]); 1177 1178 1178 1179 res=CreateFileMoniker(relPath,ppmkRelPath); 1179 1180 1180 1181 for(j=0; tabStr1[j]!=NULL;j++) 1181 1182 CoTaskMemFree(tabStr1[j]); … … 1219 1220 1220 1221 strcpyW(*ppszDisplayName,This->filePathName); 1221 1222 1222 1223 return S_OK; 1223 1224 } … … 1246 1247 if (!pwdMksys) 1247 1248 return E_POINTER; 1248 1249 1249 1250 (*pwdMksys)=MKSYS_FILEMONIKER; 1250 1251 … … 1283 1284 { 1284 1285 ICOM_THIS_From_IROTData(IMoniker, iface); 1285 1286 1286 1287 TRACE("(%p)\n",This); 1287 1288 … … 1327 1328 if(lpszPathName==NULL) 1328 1329 return MK_E_SYNTAX; 1329 1330 1330 1331 *ppmk=0; 1331 1332 1332 1333 newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl)); 1333 1334 … … 1338 1339 1339 1340 if (SUCCEEDED(hr)) 1340 1341 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&riid,(void**)ppmk); 1341 1342 else 1342 1343 HeapFree(GetProcessHeap(),0,newFileMoniker);
Note:
See TracChangeset
for help on using the changeset viewer.