ChangeLog: 1. Close file that is associated to the ole storage resource when it's being released or when it failed to be created. 2. Zero-out the output struture of a IEnumSTATSTG::Next call if the function returns false like it does on Windows. 3. Added Unix path conversion to DOS-style in StgCreateDocfile and StgOpenStorage. Description: 2. The STATSTG output structure in IEnumSTATSTGImpl_Next function must be zeroed-out cause most of the time the caller won't look that the return code but rather test if STATSTG->type is zero. It behaves the same way on Windows. 3. Call GetFullPathNameW on the input path before calling CreateFileW in StgCreateDocfile and StgOpenStorage to ensure that CreateFileW gets a DOS-style path. Warren Baird : Warren_Baird@cimmetry.com Dave Belanger diff -ur clean/wine/dlls/ole32/storage32.c wine/dlls/ole32/storage32.c --- clean/wine/dlls/ole32/storage32.c Thu Jan 30 14:09:53 2003 +++ wine/dlls/ole32/storage32.c Thu Jan 30 15:30:43 2003 @@ -2400,6 +2400,8 @@ if(This->pwcsName) HeapFree(GetProcessHeap(), 0, This->pwcsName); + CloseHandle(This->hFile); + BlockChainStream_Destroy(This->smallBlockRootChain); BlockChainStream_Destroy(This->rootBlockChain); BlockChainStream_Destroy(This->smallBlockDepotChain); @@ -3742,6 +3744,12 @@ if (*pceltFetched == celt) return S_OK; + // We must zero-out the output parameter cause most of the + // time the caller doesn't look that the return code but + // rather test if rgelt->type is zero. + // It behaves the same way on Windows. + memset(rgelt, 0, sizeof(STATSTG)); + return S_FALSE; } @@ -5419,6 +5427,7 @@ DWORD creationMode; DWORD fileAttributes; WCHAR tempFileName[MAX_PATH]; + WCHAR fullname[MAX_PATH]; TRACE("(%s, %lx, %ld, %p)\n", debugstr_w(pwcsName), grfMode, @@ -5486,7 +5495,9 @@ */ *ppstgOpen = 0; - hFile = CreateFileW(pwcsName, + GetFullPathNameW(pwcsName, MAX_PATH, fullname, NULL); + + hFile = CreateFileW(fullname, accessMode, shareMode, NULL, @@ -5504,13 +5515,15 @@ */ newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl)); - if (newStorage == 0) - return STG_E_INSUFFICIENTMEMORY; + if (newStorage == 0) { + CloseHandle(hFile); + return STG_E_INSUFFICIENTMEMORY; + } hr = StorageImpl_Construct( newStorage, hFile, - pwcsName, + fullname, NULL, grfMode, TRUE, @@ -5518,6 +5531,7 @@ if (FAILED(hr)) { + CloseHandle(hFile); HeapFree(GetProcessHeap(), 0, newStorage); return hr; } @@ -5585,7 +5599,9 @@ */ *ppstgOpen = 0; - hFile = CreateFileW( pwcsName, + GetFullPathNameW(pwcsName, MAX_PATH, fullname, NULL); + + hFile = CreateFileW( fullname, accessMode, shareMode, NULL, @@ -5642,7 +5658,7 @@ hr = StorageImpl_Construct( newStorage, hFile, - pwcsName, + fullname, NULL, grfMode, TRUE, @@ -5659,8 +5675,6 @@ goto end; } - /* prepare the file name string given in lieu of the root property name */ - GetFullPathNameW(pwcsName, MAX_PATH, fullname, NULL); memcpy(newStorage->filename, fullname, PROPERTY_NAME_BUFFER_LEN); newStorage->filename[PROPERTY_NAME_BUFFER_LEN-1] = '\0'; @@ -5674,6 +5688,11 @@ end: TRACE("<-- %08lx, IStorage %p\n", hr, ppstgOpen ? *ppstgOpen : NULL); + + if (FAILED(hr)) { + CloseHandle(hFile); + } + return hr; }