DWORD openFlags,
BOOL fileBased,
BOOL create,
+ ULONG sector_size,
StorageImpl** result)
{
StorageImpl* This;
/*
* Initialize the big block cache.
*/
- This->bigBlockSize = DEF_BIG_BLOCK_SIZE;
+ This->bigBlockSize = sector_size;
This->smallBlockSize = DEF_SMALL_BLOCK_SIZE;
This->bigBlockFile = BIGBLOCKFILE_Construct(hFile,
pLkbyt,
This->rootStartBlock = 1;
This->smallBlockLimit = LIMIT_TO_USE_SMALL_BLOCK;
This->smallBlockDepotStart = BLOCK_END_OF_CHAIN;
- This->bigBlockSizeBits = DEF_BIG_BLOCK_SIZE_BITS;
+ if (sector_size == 4096)
+ This->bigBlockSizeBits = MAX_BIG_BLOCK_SIZE_BITS;
+ else
+ This->bigBlockSizeBits = MIN_BIG_BLOCK_SIZE_BITS;
This->smallBlockSizeBits = DEF_SMALL_BLOCK_SIZE_BITS;
This->extBigBlockDepotStart = BLOCK_END_OF_CHAIN;
This->extBigBlockDepotCount = 0;
DWORD openFlags,
BOOL fileBased,
BOOL create,
+ ULONG sector_size,
StorageBaseImpl** result)
{
StorageImpl *newStorage;
StorageBaseImpl *newTransactedStorage;
HRESULT hr;
- hr = StorageImpl_Construct(hFile, pwcsName, pLkbyt, openFlags, fileBased, create, &newStorage);
+ hr = StorageImpl_Construct(hFile, pwcsName, pLkbyt, openFlags, fileBased, create, sector_size, &newStorage);
if (FAILED(hr)) goto end;
if (openFlags & STGM_TRANSACTED)
return chainEntry.size;
}
-/******************************************************************************
- * StgCreateDocfile [OLE32.@]
- * Creates a new compound file storage object
- *
- * PARAMS
- * pwcsName [ I] Unicode string with filename (can be relative or NULL)
- * grfMode [ I] Access mode for opening the new storage object (see STGM_ constants)
- * reserved [ ?] unused?, usually 0
- * ppstgOpen [IO] A pointer to IStorage pointer to the new onject
- *
- * RETURNS
- * S_OK if the file was successfully created
- * some STG_E_ value if error
- * NOTES
- * if pwcsName is NULL, create file with new unique name
- * the function can returns
- * STG_S_CONVERTED if the specified file was successfully converted to storage format
- * (unrealized now)
- */
-HRESULT WINAPI StgCreateDocfile(
+static HRESULT create_storagefile(
LPCOLESTR pwcsName,
DWORD grfMode,
- DWORD reserved,
- IStorage **ppstgOpen)
+ DWORD grfAttrs,
+ STGOPTIONS* pStgOptions,
+ REFIID riid,
+ void** ppstgOpen)
{
StorageBaseImpl* newStorage = 0;
HANDLE hFile = INVALID_HANDLE_VALUE;
DWORD fileAttributes;
WCHAR tempFileName[MAX_PATH];
- TRACE("(%s, %x, %d, %p)\n",
- debugstr_w(pwcsName), grfMode,
- reserved, ppstgOpen);
-
if (ppstgOpen == 0)
return STG_E_INVALIDPOINTER;
- if (reserved != 0)
+
+ if (pStgOptions->ulSectorSize != MIN_BIG_BLOCK_SIZE && pStgOptions->ulSectorSize != MAX_BIG_BLOCK_SIZE)
return STG_E_INVALIDPARAMETER;
/* if no share mode given then DENY_NONE is the default */
grfMode,
TRUE,
TRUE,
+ pStgOptions->ulSectorSize,
&newStorage);
if (FAILED(hr))
goto end;
}
- /*
- * Get an "out" pointer for the caller.
- */
- *ppstgOpen = (IStorage*)newStorage;
+ hr = IStorage_QueryInterface((IStorage*)newStorage, riid, ppstgOpen);
+
+ IStorage_Release((IStorage*)newStorage);
end:
TRACE("<-- %p r = %08x\n", *ppstgOpen, hr);
return hr;
}
+/******************************************************************************
+ * StgCreateDocfile [OLE32.@]
+ * Creates a new compound file storage object
+ *
+ * PARAMS
+ * pwcsName [ I] Unicode string with filename (can be relative or NULL)
+ * grfMode [ I] Access mode for opening the new storage object (see STGM_ constants)
+ * reserved [ ?] unused?, usually 0
+ * ppstgOpen [IO] A pointer to IStorage pointer to the new onject
+ *
+ * RETURNS
+ * S_OK if the file was successfully created
+ * some STG_E_ value if error
+ * NOTES
+ * if pwcsName is NULL, create file with new unique name
+ * the function can returns
+ * STG_S_CONVERTED if the specified file was successfully converted to storage format
+ * (unrealized now)
+ */
+HRESULT WINAPI StgCreateDocfile(
+ LPCOLESTR pwcsName,
+ DWORD grfMode,
+ DWORD reserved,
+ IStorage **ppstgOpen)
+{
+ STGOPTIONS stgoptions = {1, 0, 512};
+
+ TRACE("(%s, %x, %d, %p)\n",
+ debugstr_w(pwcsName), grfMode,
+ reserved, ppstgOpen);
+
+ if (ppstgOpen == 0)
+ return STG_E_INVALIDPOINTER;
+ if (reserved != 0)
+ return STG_E_INVALIDPARAMETER;
+
+ return create_storagefile(pwcsName, grfMode, 0, &stgoptions, &IID_IStorage, (void**)ppstgOpen);
+}
+
/******************************************************************************
* StgCreateStorageEx [OLE32.@]
*/
if (stgfmt == STGFMT_STORAGE || stgfmt == STGFMT_DOCFILE)
{
- FIXME("Stub: calling StgCreateDocfile, but ignoring pStgOptions and grfAttrs\n");
- return StgCreateDocfile(pwcsName, grfMode, 0, (IStorage **)ppObjectOpen);
+ return create_storagefile(pwcsName, grfMode, grfAttrs, pStgOptions, riid, ppObjectOpen);
}
+
ERR("Invalid stgfmt argument\n");
return STG_E_INVALIDPARAMETER;
}
grfMode,
TRUE,
FALSE,
+ 512,
&newStorage);
if (FAILED(hr))
grfMode,
FALSE,
TRUE,
+ 512,
&newStorage);
if (FAILED(hr))
grfMode,
FALSE,
FALSE,
+ 512,
&newStorage);
if (FAILED(hr))