DirRef transactedParentEntry;
/* True if this entry is being used. */
- int inuse;
+ BOOL inuse;
/* True if data is up to date. */
- int read;
+ BOOL read;
/* True if this entry has been modified. */
- int dirty;
+ BOOL dirty;
/* True if this entry's stream has been modified. */
- int stream_dirty;
+ BOOL stream_dirty;
/* True if this entry has been deleted in the transacted storage, but the
* delete has not yet been committed. */
- int deleted;
+ BOOL deleted;
/* If this entry's stream has been modified, a reference to where the stream
* is stored in the snapshot file. */
* The root storage contains some element, therefore, start the research
* for the appropriate location.
*/
- BOOL found = 0;
+ BOOL found = FALSE;
DirRef current, next, previous, currentEntryId;
/*
next = currentEntry.rightChild;
current = currentEntryId;
- while (found == 0)
+ while (!found)
{
LONG diff = entryNameCmp( newEntry.name, currentEntry.name);
StorageBaseImpl_WriteDirEntry(This,
current,
¤tEntry);
- found = 1;
+ found = TRUE;
}
}
else if (diff > 0)
StorageBaseImpl_WriteDirEntry(This,
current,
¤tEntry);
- found = 1;
+ found = TRUE;
}
}
else
else
This->base.lockingrole = SWMR_None;
- This->base.reverted = 0;
+ This->base.reverted = FALSE;
/*
* Initialize the big block cache.
StorageBaseImpl_DeleteAll(&This->base);
- This->base.reverted = 1;
+ This->base.reverted = TRUE;
}
static void StorageImpl_Destroy(StorageBaseImpl* iface)
This->entries_size = new_size;
}
- This->entries[result].inuse = 1;
+ This->entries[result].inuse = TRUE;
This->firstFreeEntry = result+1;
entry->newTransactedParentEntry = entry->transactedParentEntry = parentEntryRef;
- entry->read = 0;
+ entry->read = FALSE;
}
return stubEntryRef;
if (SUCCEEDED(hr))
{
memcpy(&This->entries[entry].data, &data, sizeof(DirEntry));
- This->entries[entry].read = 1;
+ This->entries[entry].read = TRUE;
}
}
}
if (SUCCEEDED(hr))
- This->entries[entry].stream_dirty = 1;
+ This->entries[entry].stream_dirty = TRUE;
if (This->entries[entry].transactedParentEntry != DIRENTRY_NULL)
{
delete_ref = TransactedSnapshotImpl_CreateStubEntry(This, This->entries[entry].transactedParentEntry);
if (delete_ref != DIRENTRY_NULL)
- This->entries[delete_ref].deleted = 1;
+ This->entries[delete_ref].deleted = TRUE;
This->entries[entry].transactedParentEntry = This->entries[entry].newTransactedParentEntry = DIRENTRY_NULL;
}
{
StorageBaseImpl_StreamSetSize(This->scratch, entry->stream_entry, zero);
StorageBaseImpl_DestroyDirEntry(This->scratch, entry->stream_entry);
- entry->stream_dirty = 0;
+ entry->stream_dirty = FALSE;
}
- entry->dirty = 0;
+ entry->dirty = FALSE;
entry->transactedParentEntry = entry->newTransactedParentEntry;
}
}
{
TRACE("Storage invalidated (stg=%p)\n", This);
- This->reverted = 1;
+ This->reverted = TRUE;
StorageBaseImpl_DeleteAll(This);
}
new_entry = &This->entries[new_ref];
new_entry->newTransactedParentEntry = new_entry->transactedParentEntry = DIRENTRY_NULL;
- new_entry->read = 1;
- new_entry->dirty = 1;
+ new_entry->read = TRUE;
+ new_entry->dirty = TRUE;
memcpy(&new_entry->data, newData, sizeof(DirEntry));
*index = new_ref;
if (index != This->base.storageDirEntry)
{
- This->entries[index].dirty = 1;
+ This->entries[index].dirty = TRUE;
if (data->size.QuadPart == 0 &&
This->entries[index].transactedParentEntry != DIRENTRY_NULL)
delete_ref = TransactedSnapshotImpl_CreateStubEntry(This, This->entries[index].transactedParentEntry);
if (delete_ref != DIRENTRY_NULL)
- This->entries[delete_ref].deleted = 1;
+ This->entries[delete_ref].deleted = TRUE;
This->entries[index].transactedParentEntry = This->entries[index].newTransactedParentEntry = DIRENTRY_NULL;
}
}
else
{
- This->entries[index].deleted = 1;
+ This->entries[index].deleted = TRUE;
}
return S_OK;
This->entries[index].stream_entry, zero);
StorageBaseImpl_DestroyDirEntry(This->scratch,
This->entries[index].stream_entry);
- This->entries[index].stream_dirty = 0;
+ This->entries[index].stream_dirty = FALSE;
}
else if (This->entries[index].transactedParentEntry != DIRENTRY_NULL)
{
delete_ref = TransactedSnapshotImpl_CreateStubEntry(This, This->entries[index].transactedParentEntry);
if (delete_ref != DIRENTRY_NULL)
- This->entries[delete_ref].deleted = 1;
+ This->entries[delete_ref].deleted = TRUE;
This->entries[index].transactedParentEntry = This->entries[index].newTransactedParentEntry = DIRENTRY_NULL;
}
{
TRACE("Storage invalidated (stg=%p)\n", This);
- This->base.reverted = 1;
+ This->base.reverted = TRUE;
This->parentStorage = NULL;
newStorage->base.baseVtbl = &StorageInternalImpl_BaseVtbl;
newStorage->base.openFlags = (openFlags & ~STGM_CREATE);
- newStorage->base.reverted = 0;
+ newStorage->base.reverted = FALSE;
newStorage->base.ref = 1;
*/
newStorage->base.storageDirEntry = storageDirEntry;
- newStorage->base.create = 0;
+ newStorage->base.create = FALSE;
return newStorage;
}
{
if (!StorageImpl_WriteBigBlock(This->parentStorage, result->sector, result->data))
return STG_E_WRITEFAULT;
- result->dirty = 0;
+ result->dirty = FALSE;
}
- result->read = 0;
+ result->read = FALSE;
result->index = index;
result->sector = *sector;
}
newStream->indexCacheLen = 0;
newStream->indexCacheSize = 0;
newStream->cachedBlocks[0].index = 0xffffffff;
- newStream->cachedBlocks[0].dirty = 0;
+ newStream->cachedBlocks[0].dirty = FALSE;
newStream->cachedBlocks[1].index = 0xffffffff;
- newStream->cachedBlocks[1].dirty = 0;
+ newStream->cachedBlocks[1].dirty = FALSE;
newStream->blockToEvict = 0;
if (FAILED(BlockChainStream_UpdateIndexCache(newStream)))
if (This->cachedBlocks[i].dirty)
{
if (StorageImpl_WriteBigBlock(This->parentStorage, This->cachedBlocks[i].sector, This->cachedBlocks[i].data))
- This->cachedBlocks[i].dirty = 0;
+ This->cachedBlocks[i].dirty = FALSE;
else
return STG_E_WRITEFAULT;
}
if (FAILED(StorageImpl_ReadBigBlock(This->parentStorage, cachedBlock->sector, cachedBlock->data, &read)) && !read)
return STG_E_READFAULT;
- cachedBlock->read = 1;
+ cachedBlock->read = TRUE;
}
memcpy(bufferWalker, cachedBlock->data+offsetInBlock, bytesToReadInBuffer);
memcpy(cachedBlock->data+offsetInBlock, bufferWalker, bytesToWrite);
bytesWrittenAt = bytesToWrite;
- cachedBlock->read = 1;
- cachedBlock->dirty = 1;
+ cachedBlock->read = TRUE;
+ cachedBlock->dirty = TRUE;
}
blockNoInSequence++;
if (This->cachedBlocks[i].index >= numBlocks)
{
This->cachedBlocks[i].index = 0xffffffff;
- This->cachedBlocks[i].dirty = 0;
+ This->cachedBlocks[i].dirty = FALSE;
}
}
HANDLE hFile = 0;
DWORD shareMode;
DWORD accessMode;
+ LPWSTR temp_name = NULL;
TRACE("(%s, %p, %x, %p, %d, %p)\n",
debugstr_w(pwcsName), pstgPriority, grfMode,
snbExclude, reserved, ppstgOpen);
+ if (pstgPriority)
+ {
+ /* FIXME: Copy ILockBytes instead? But currently for STGM_PRIORITY it'll be read-only. */
+ hr = StorageBaseImpl_GetFilename((StorageBaseImpl*)pstgPriority, &temp_name);
+ if (FAILED(hr)) goto end;
+ pwcsName = temp_name;
+ TRACE("using filename %s\n", debugstr_w(temp_name));
+ }
+
if (pwcsName == 0)
{
hr = STG_E_INVALIDNAME;
*ppstgOpen = &newStorage->IStorage_iface;
end:
+ CoTaskMemFree(temp_name);
+ if (pstgPriority) IStorage_Release(pstgPriority);
TRACE("<-- %08x, IStorage %p\n", hr, ppstgOpen ? *ppstgOpen : NULL);
return hr;
}
len = MultiByteToWideChar( CP_ACP, 0, str, count, NULL, 0 );
wstr = CoTaskMemAlloc( (len + 1)*sizeof (WCHAR) );
if( wstr )
+ {
MultiByteToWideChar( CP_ACP, 0, str, count, wstr, len );
+ wstr[len] = 0;
+ }
CoTaskMemFree( str );
*string = wstr;
HRESULT WINAPI WriteFmtUserTypeStg(
LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR lpszUserType)
{
+ STATSTG stat;
HRESULT r;
WCHAR szwClipName[0x40];
- CLSID clsid = CLSID_NULL;
+ CLSID clsid;
LPWSTR wstrProgID = NULL;
DWORD n;
TRACE("(%p,%x,%s)\n",pstg,cf,debugstr_w(lpszUserType));
/* get the clipboard format name */
- n = GetClipboardFormatNameW( cf, szwClipName, sizeof(szwClipName)/sizeof(szwClipName[0]) );
- szwClipName[n]=0;
+ if( cf )
+ {
+ n = GetClipboardFormatNameW( cf, szwClipName,
+ sizeof(szwClipName)/sizeof(szwClipName[0]) );
+ szwClipName[n]=0;
+ }
TRACE("Clipboard name is %s\n", debugstr_w(szwClipName));
- /* FIXME: There's room to save a CLSID and its ProgID, but
- the CLSID is not looked up in the registry and in all the
- tests I wrote it was CLSID_NULL. Where does it come from?
- */
+ r = IStorage_Stat(pstg, &stat, STATFLAG_NONAME);
+ if(SUCCEEDED(r))
+ clsid = stat.clsid;
+ else
+ clsid = CLSID_NULL;
- /* get the real program ID. This may fail, but that's fine */
ProgIDFromCLSID(&clsid, &wstrProgID);
TRACE("progid is %s\n",debugstr_w(wstrProgID));
- r = STORAGE_WriteCompObj( pstg, &clsid,
- lpszUserType, szwClipName, wstrProgID );
+ r = STORAGE_WriteCompObj( pstg, &clsid, lpszUserType,
+ cf ? szwClipName : NULL, wstrProgID );
CoTaskMemFree(wstrProgID);
*/
HRESULT WINAPI SetConvertStg(IStorage *storage, BOOL convert)
{
+ static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
DWORD flags = convert ? OleStream_Convert : 0;
+ IStream *stream;
+ DWORD header[2];
HRESULT hr;
TRACE("(%p, %d)\n", storage, convert);
- hr = STORAGE_CreateOleStream(storage, flags);
- if (hr == STG_E_FILEALREADYEXISTS)
+ hr = IStorage_OpenStream(storage, stream_1oleW, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
+ if (FAILED(hr))
{
- static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
- IStream *stream;
- DWORD header[2];
+ if (hr != STG_E_FILENOTFOUND)
+ return hr;
- hr = IStorage_OpenStream(storage, stream_1oleW, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
- if (FAILED(hr)) return hr;
+ return STORAGE_CreateOleStream(storage, flags);
+ }
- hr = IStream_Read(stream, header, sizeof(header), NULL);
+ hr = IStream_Read(stream, header, sizeof(header), NULL);
+ if (FAILED(hr))
+ {
+ IStream_Release(stream);
+ return hr;
+ }
+
+ /* update flag if differs */
+ if ((header[1] ^ flags) & OleStream_Convert)
+ {
+ LARGE_INTEGER pos = {{0}};
+
+ if (header[1] & OleStream_Convert)
+ flags = header[1] & ~OleStream_Convert;
+ else
+ flags = header[1] | OleStream_Convert;
+
+ pos.QuadPart = sizeof(DWORD);
+ hr = IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL);
if (FAILED(hr))
{
IStream_Release(stream);
return hr;
}
- /* update flag if differs */
- if ((header[1] ^ flags) & OleStream_Convert)
- {
- LARGE_INTEGER pos;
-
- if (header[1] & OleStream_Convert)
- flags = header[1] & ~OleStream_Convert;
- else
- flags = header[1] | OleStream_Convert;
-
- pos.QuadPart = sizeof(DWORD);
- hr = IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL);
- if (FAILED(hr))
- {
- IStream_Release(stream);
- return hr;
- }
-
- hr = IStream_Write(stream, &flags, sizeof(flags), NULL);
- }
- IStream_Release(stream);
+ hr = IStream_Write(stream, &flags, sizeof(flags), NULL);
}
+ IStream_Release(stream);
return hr;
}