Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
79f7318a
Commit
79f7318a
authored
Sep 11, 2006
by
Robert Shearman
Committed by
Alexandre Julliard
Sep 11, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: Convert the *_{Read,Write}At structured storage functions to
return HRESULTs instead of BOOLs so that errors can be properly propagated from lower levels.
parent
bfc1bdc3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
62 deletions
+67
-62
stg_stream.c
dlls/ole32/stg_stream.c
+11
-12
storage32.c
dlls/ole32/storage32.c
+53
-47
storage32.h
dlls/ole32/storage32.h
+3
-3
No files found.
dlls/ole32/stg_stream.c
View file @
79f7318a
...
...
@@ -302,15 +302,11 @@ static HRESULT WINAPI StgStreamImpl_Read(
}
else
if
(
This
->
bigBlockChain
!=
0
)
{
BOOL
success
=
BlockChainStream_ReadAt
(
This
->
bigBlockChain
,
This
->
currentPosition
,
bytesToReadFromBuffer
,
pv
,
pcbRead
);
if
(
success
)
res
=
S_OK
;
else
res
=
STG_E_READFAULT
;
res
=
BlockChainStream_ReadAt
(
This
->
bigBlockChain
,
This
->
currentPosition
,
bytesToReadFromBuffer
,
pv
,
pcbRead
);
}
else
{
...
...
@@ -363,6 +359,7 @@ static HRESULT WINAPI StgStreamImpl_Write(
ULARGE_INTEGER
newSize
;
ULONG
bytesWritten
=
0
;
HRESULT
res
;
TRACE
(
"(%p, %p, %ld, %p)
\n
"
,
iface
,
pv
,
cb
,
pcbWritten
);
...
...
@@ -427,7 +424,7 @@ static HRESULT WINAPI StgStreamImpl_Write(
*/
if
(
This
->
smallBlockChain
!=
0
)
{
SmallBlockChainStream_WriteAt
(
This
->
smallBlockChain
,
res
=
SmallBlockChainStream_WriteAt
(
This
->
smallBlockChain
,
This
->
currentPosition
,
cb
,
pv
,
...
...
@@ -436,13 +433,15 @@ static HRESULT WINAPI StgStreamImpl_Write(
}
else
if
(
This
->
bigBlockChain
!=
0
)
{
BlockChainStream_WriteAt
(
This
->
bigBlockChain
,
res
=
BlockChainStream_WriteAt
(
This
->
bigBlockChain
,
This
->
currentPosition
,
cb
,
pv
,
pcbWritten
);
}
else
/* this should never happen because the IStream_SetSize call above will
* make sure a big or small block chain is created */
assert
(
FALSE
);
/*
...
...
@@ -451,7 +450,7 @@ static HRESULT WINAPI StgStreamImpl_Write(
This
->
currentPosition
.
u
.
LowPart
+=
*
pcbWritten
;
TRACE
(
"<-- S_OK, written %lu
\n
"
,
*
pcbWritten
);
return
S_OK
;
return
res
;
}
/***
...
...
dlls/ole32/storage32.c
View file @
79f7318a
...
...
@@ -3303,20 +3303,20 @@ BOOL StorageImpl_ReadProperty(
{
BYTE
currentProperty
[
PROPSET_BLOCK_SIZE
];
ULARGE_INTEGER
offsetInPropSet
;
BOOL
readSuccessful
;
HRESULT
readRes
;
ULONG
bytesRead
;
offsetInPropSet
.
u
.
HighPart
=
0
;
offsetInPropSet
.
u
.
LowPart
=
index
*
PROPSET_BLOCK_SIZE
;
read
Successful
=
BlockChainStream_ReadAt
(
read
Res
=
BlockChainStream_ReadAt
(
This
->
rootBlockChain
,
offsetInPropSet
,
PROPSET_BLOCK_SIZE
,
currentProperty
,
&
bytesRead
);
if
(
readSuccessful
)
if
(
SUCCEEDED
(
readRes
)
)
{
/* replace the name of root entry (often "Root Entry") by the file name */
WCHAR
*
propName
=
(
index
==
This
->
base
.
rootPropertySetIndex
)
?
...
...
@@ -3389,7 +3389,7 @@ BOOL StorageImpl_ReadProperty(
buffer
->
size
.
u
.
HighPart
=
0
;
}
return
readSuccessful
;
return
SUCCEEDED
(
readRes
)
?
TRUE
:
FALSE
;
}
/*********************************************************************
...
...
@@ -3402,7 +3402,7 @@ BOOL StorageImpl_WriteProperty(
{
BYTE
currentProperty
[
PROPSET_BLOCK_SIZE
];
ULARGE_INTEGER
offsetInPropSet
;
BOOL
writeSuccessful
;
HRESULT
writeRes
;
ULONG
bytesWritten
;
offsetInPropSet
.
u
.
HighPart
=
0
;
...
...
@@ -3472,12 +3472,12 @@ BOOL StorageImpl_WriteProperty(
OFFSET_PS_SIZE
,
buffer
->
size
.
u
.
LowPart
);
write
Successful
=
BlockChainStream_WriteAt
(
This
->
rootBlockChain
,
offsetInPropSet
,
PROPSET_BLOCK_SIZE
,
currentProperty
,
&
bytesWritten
);
return
writeSuccessful
;
write
Res
=
BlockChainStream_WriteAt
(
This
->
rootBlockChain
,
offsetInPropSet
,
PROPSET_BLOCK_SIZE
,
currentProperty
,
&
bytesWritten
);
return
SUCCEEDED
(
writeRes
)
?
TRUE
:
FALSE
;
}
static
BOOL
StorageImpl_ReadBigBlock
(
...
...
@@ -3557,8 +3557,8 @@ BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
ULARGE_INTEGER
size
,
offset
;
ULONG
cbRead
,
cbWritten
,
cbTotalRead
,
cbTotalWritten
;
ULONG
propertyIndex
;
BOOL
succes
sWrite
;
HRESULT
succes
sRead
;
HRESULT
re
sWrite
;
HRESULT
re
sRead
;
StgProperty
chainProperty
;
BYTE
*
buffer
;
BlockChainStream
*
bbTempChain
=
NULL
;
...
...
@@ -3591,25 +3591,25 @@ BlockChainStream* Storage32Impl_SmallBlocksToBigBlocks(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
DEF_SMALL_BLOCK_SIZE
);
do
{
succes
sRead
=
SmallBlockChainStream_ReadAt
(
*
ppsbChain
,
offset
,
DEF_SMALL_BLOCK_SIZE
,
buffer
,
&
cbRead
);
if
(
FAILED
(
succes
sRead
))
re
sRead
=
SmallBlockChainStream_ReadAt
(
*
ppsbChain
,
offset
,
DEF_SMALL_BLOCK_SIZE
,
buffer
,
&
cbRead
);
if
(
FAILED
(
re
sRead
))
break
;
if
(
cbRead
>
0
)
{
cbTotalRead
+=
cbRead
;
succes
sWrite
=
BlockChainStream_WriteAt
(
bbTempChain
,
re
sWrite
=
BlockChainStream_WriteAt
(
bbTempChain
,
offset
,
cbRead
,
buffer
,
&
cbWritten
);
if
(
!
successWrite
)
if
(
FAILED
(
resWrite
)
)
break
;
cbTotalWritten
+=
cbWritten
;
...
...
@@ -4516,7 +4516,7 @@ static ULONG BlockChainStream_GetCount(BlockChainStream* This)
* bytesRead may be NULL.
* Failure will be returned if the specified number of bytes has not been read.
*/
BOOL
BlockChainStream_ReadAt
(
BlockChainStream
*
This
,
HRESULT
BlockChainStream_ReadAt
(
BlockChainStream
*
This
,
ULARGE_INTEGER
offset
,
ULONG
size
,
void
*
buffer
,
...
...
@@ -4551,12 +4551,12 @@ BOOL BlockChainStream_ReadAt(BlockChainStream* This,
while
(
(
blockNoInSequence
>
0
)
&&
(
blockIndex
!=
BLOCK_END_OF_CHAIN
))
{
if
(
FAILED
(
StorageImpl_GetNextBlockInChain
(
This
->
parentStorage
,
blockIndex
,
&
blockIndex
)))
return
FALSE
;
return
STG_E_DOCFILECORRUPT
;
blockNoInSequence
--
;
}
if
((
blockNoInSequence
>
0
)
&&
(
blockIndex
==
BLOCK_END_OF_CHAIN
))
return
FALSE
;
/* We failed to find the starting block */
return
STG_E_DOCFILECORRUPT
;
/* We failed to find the starting block */
This
->
lastBlockNoInSequenceIndex
=
blockIndex
;
...
...
@@ -4580,7 +4580,7 @@ BOOL BlockChainStream_ReadAt(BlockChainStream* This,
bigBlockBuffer
=
StorageImpl_GetROBigBlock
(
This
->
parentStorage
,
blockIndex
);
if
(
!
bigBlockBuffer
)
return
FALSE
;
return
STG_E_READFAULT
;
memcpy
(
bufferWalker
,
bigBlockBuffer
+
offsetInBlock
,
bytesToReadInBuffer
);
...
...
@@ -4590,7 +4590,7 @@ BOOL BlockChainStream_ReadAt(BlockChainStream* This,
* Step to the next big block.
*/
if
(
FAILED
(
StorageImpl_GetNextBlockInChain
(
This
->
parentStorage
,
blockIndex
,
&
blockIndex
)))
return
FALSE
;
return
STG_E_DOCFILECORRUPT
;
bufferWalker
+=
bytesToReadInBuffer
;
size
-=
bytesToReadInBuffer
;
...
...
@@ -4599,7 +4599,7 @@ BOOL BlockChainStream_ReadAt(BlockChainStream* This,
}
return
(
size
==
0
);
return
(
size
==
0
)
?
S_OK
:
STG_E_READFAULT
;
}
/******************************************************************************
...
...
@@ -4609,7 +4609,7 @@ BOOL BlockChainStream_ReadAt(BlockChainStream* This,
* bytesWritten may be NULL.
* Will fail if not all specified number of bytes have been written.
*/
BOOL
BlockChainStream_WriteAt
(
BlockChainStream
*
This
,
HRESULT
BlockChainStream_WriteAt
(
BlockChainStream
*
This
,
ULARGE_INTEGER
offset
,
ULONG
size
,
const
void
*
buffer
,
...
...
@@ -4645,7 +4645,7 @@ BOOL BlockChainStream_WriteAt(BlockChainStream* This,
{
if
(
FAILED
(
StorageImpl_GetNextBlockInChain
(
This
->
parentStorage
,
blockIndex
,
&
blockIndex
)))
return
FALSE
;
return
STG_E_DOCFILECORRUPT
;
blockNoInSequence
--
;
}
...
...
@@ -4680,14 +4680,14 @@ BOOL BlockChainStream_WriteAt(BlockChainStream* This,
*/
if
(
FAILED
(
StorageImpl_GetNextBlockInChain
(
This
->
parentStorage
,
blockIndex
,
&
blockIndex
)))
return
FALSE
;
return
STG_E_DOCFILECORRUPT
;
bufferWalker
+=
bytesToWrite
;
size
-=
bytesToWrite
;
*
bytesWritten
+=
bytesToWrite
;
offsetInBlock
=
0
;
/* There is no offset on the next block */
}
return
(
size
==
0
);
return
(
size
==
0
)
?
S_OK
:
STG_E_WRITEFAULT
;
}
/******************************************************************************
...
...
@@ -5010,7 +5010,7 @@ static HRESULT SmallBlockChainStream_GetNextBlockInChain(
ULARGE_INTEGER
offsetOfBlockInDepot
;
DWORD
buffer
;
ULONG
bytesRead
;
BOOL
succes
s
;
HRESULT
re
s
;
*
nextBlockInChain
=
BLOCK_END_OF_CHAIN
;
...
...
@@ -5020,20 +5020,20 @@ static HRESULT SmallBlockChainStream_GetNextBlockInChain(
/*
* Read those bytes in the buffer from the small block file.
*/
succes
s
=
BlockChainStream_ReadAt
(
re
s
=
BlockChainStream_ReadAt
(
This
->
parentStorage
->
smallBlockDepotChain
,
offsetOfBlockInDepot
,
sizeof
(
DWORD
),
&
buffer
,
&
bytesRead
);
if
(
success
)
if
(
SUCCEEDED
(
res
)
)
{
StorageUtl_ReadDWord
((
BYTE
*
)
&
buffer
,
0
,
nextBlockInChain
);
return
S_OK
;
}
return
STG_E_READFAULT
;
return
res
;
}
/******************************************************************************
...
...
@@ -5096,7 +5096,7 @@ static ULONG SmallBlockChainStream_GetNextFreeBlock(
ULONG
bytesRead
;
ULONG
blockIndex
=
0
;
ULONG
nextBlockIndex
=
BLOCK_END_OF_CHAIN
;
BOOL
success
=
TRUE
;
HRESULT
res
=
S_OK
;
ULONG
smallBlocksPerBigBlock
;
offsetOfBlockInDepot
.
u
.
HighPart
=
0
;
...
...
@@ -5108,7 +5108,7 @@ static ULONG SmallBlockChainStream_GetNextFreeBlock(
{
offsetOfBlockInDepot
.
u
.
LowPart
=
blockIndex
*
sizeof
(
ULONG
);
succes
s
=
BlockChainStream_ReadAt
(
re
s
=
BlockChainStream_ReadAt
(
This
->
parentStorage
->
smallBlockDepotChain
,
offsetOfBlockInDepot
,
sizeof
(
DWORD
),
...
...
@@ -5118,7 +5118,7 @@ static ULONG SmallBlockChainStream_GetNextFreeBlock(
/*
* If we run out of space for the small block depot, enlarge it
*/
if
(
success
)
if
(
SUCCEEDED
(
res
)
)
{
StorageUtl_ReadDWord
((
BYTE
*
)
&
buffer
,
0
,
&
nextBlockIndex
);
...
...
@@ -5310,12 +5310,14 @@ HRESULT SmallBlockChainStream_ReadAt(
* The small block has already been identified so it shouldn't fail
* unless the file is corrupt.
*/
if
(
!
BlockChainStream_ReadAt
(
This
->
parentStorage
->
smallBlockRootChain
,
rc
=
BlockChainStream_ReadAt
(
This
->
parentStorage
->
smallBlockRootChain
,
offsetInBigBlockFile
,
bytesToReadInBuffer
,
bufferWalker
,
&
bytesReadFromBigBlockFile
))
return
STG_E_DOCFILECORRUPT
;
&
bytesReadFromBigBlockFile
);
if
(
FAILED
(
rc
))
return
rc
;
assert
(
bytesReadFromBigBlockFile
==
bytesToReadInBuffer
);
...
...
@@ -5324,7 +5326,7 @@ HRESULT SmallBlockChainStream_ReadAt(
*/
rc
=
SmallBlockChainStream_GetNextBlockInChain
(
This
,
blockIndex
,
&
blockIndex
);
if
(
FAILED
(
rc
))
return
rc
;
return
STG_E_DOCFILECORRUPT
;
bufferWalker
+=
bytesToReadInBuffer
;
size
-=
bytesToReadInBuffer
;
...
...
@@ -5332,7 +5334,7 @@ HRESULT SmallBlockChainStream_ReadAt(
offsetInBlock
=
0
;
/* There is no offset on the next block */
}
return
rc
;
return
(
size
==
0
)
?
S_OK
:
STG_E_READFAULT
;
}
/******************************************************************************
...
...
@@ -5342,7 +5344,7 @@ HRESULT SmallBlockChainStream_ReadAt(
* bytesWritten may be NULL.
* Will fail if not all specified number of bytes have been written.
*/
BOOL
SmallBlockChainStream_WriteAt
(
HRESULT
SmallBlockChainStream_WriteAt
(
SmallBlockChainStream
*
This
,
ULARGE_INTEGER
offset
,
ULONG
size
,
...
...
@@ -5358,6 +5360,7 @@ BOOL SmallBlockChainStream_WriteAt(
ULONG
blockIndex
;
ULONG
bytesWrittenFromBigBlockFile
;
const
BYTE
*
bufferWalker
;
HRESULT
res
;
/*
* This should never happen on a small block file.
...
...
@@ -5372,7 +5375,7 @@ BOOL SmallBlockChainStream_WriteAt(
while
(
(
blockNoInSequence
>
0
)
&&
(
blockIndex
!=
BLOCK_END_OF_CHAIN
))
{
if
(
FAILED
(
SmallBlockChainStream_GetNextBlockInChain
(
This
,
blockIndex
,
&
blockIndex
)))
return
FALSE
;
return
STG_E_DOCFILECORRUPT
;
blockNoInSequence
--
;
}
...
...
@@ -5404,11 +5407,14 @@ BOOL SmallBlockChainStream_WriteAt(
/*
* Write those bytes in the buffer to the small block file.
*/
BlockChainStream_WriteAt
(
This
->
parentStorage
->
smallBlockRootChain
,
res
=
BlockChainStream_WriteAt
(
This
->
parentStorage
->
smallBlockRootChain
,
offsetInBigBlockFile
,
bytesToWriteInBuffer
,
bufferWalker
,
&
bytesWrittenFromBigBlockFile
);
if
(
FAILED
(
res
))
return
res
;
assert
(
bytesWrittenFromBigBlockFile
==
bytesToWriteInBuffer
);
...
...
@@ -5424,7 +5430,7 @@ BOOL SmallBlockChainStream_WriteAt(
offsetInBlock
=
0
;
/* There is no offset on the next block */
}
return
(
size
==
0
);
return
(
size
==
0
)
?
S_OK
:
STG_E_WRITEFAULT
;
}
/******************************************************************************
...
...
dlls/ole32/storage32.h
View file @
79f7318a
...
...
@@ -455,14 +455,14 @@ BlockChainStream* BlockChainStream_Construct(
void
BlockChainStream_Destroy
(
BlockChainStream
*
This
);
BOOL
BlockChainStream_ReadAt
(
HRESULT
BlockChainStream_ReadAt
(
BlockChainStream
*
This
,
ULARGE_INTEGER
offset
,
ULONG
size
,
void
*
buffer
,
ULONG
*
bytesRead
);
BOOL
BlockChainStream_WriteAt
(
HRESULT
BlockChainStream_WriteAt
(
BlockChainStream
*
This
,
ULARGE_INTEGER
offset
,
ULONG
size
,
...
...
@@ -502,7 +502,7 @@ HRESULT SmallBlockChainStream_ReadAt(
void
*
buffer
,
ULONG
*
bytesRead
);
BOOL
SmallBlockChainStream_WriteAt
(
HRESULT
SmallBlockChainStream_WriteAt
(
SmallBlockChainStream
*
This
,
ULARGE_INTEGER
offset
,
ULONG
size
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment