Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
d0e6e4aa
Commit
d0e6e4aa
authored
Jul 17, 2010
by
Vincent Povirk
Committed by
Alexandre Julliard
Jul 19, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: Use ILockBytes_Stat to get the filename of a storage.
parent
14f8f9d5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
48 deletions
+77
-48
filelockbytes.c
dlls/ole32/filelockbytes.c
+29
-4
storage32.c
dlls/ole32/storage32.c
+41
-39
storage32.h
dlls/ole32/storage32.h
+7
-5
No files found.
dlls/ole32/filelockbytes.c
View file @
d0e6e4aa
...
...
@@ -41,6 +41,7 @@
#include "storage32.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
storage
);
...
...
@@ -51,6 +52,7 @@ typedef struct FileLockBytesImpl
ULARGE_INTEGER
filesize
;
HANDLE
hfile
;
DWORD
flProtect
;
LPWSTR
pwcsName
;
}
FileLockBytesImpl
;
static
const
ILockBytesVtbl
FileLockBytesImpl_Vtbl
;
...
...
@@ -85,9 +87,10 @@ static DWORD GetProtectMode(DWORD openFlags)
*
* Initialize a big block object supported by a file.
*/
HRESULT
FileLockBytesImpl_Construct
(
HANDLE
hFile
,
DWORD
openFlags
,
ILockBytes
**
pLockBytes
)
HRESULT
FileLockBytesImpl_Construct
(
HANDLE
hFile
,
DWORD
openFlags
,
LPCWSTR
pwcsName
,
ILockBytes
**
pLockBytes
)
{
FileLockBytesImpl
*
This
;
WCHAR
fullpath
[
MAX_PATH
];
if
(
hFile
==
INVALID_HANDLE_VALUE
)
return
E_FAIL
;
...
...
@@ -104,6 +107,23 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, ILockBytes **
&
This
->
filesize
.
u
.
HighPart
);
This
->
flProtect
=
GetProtectMode
(
openFlags
);
if
(
pwcsName
)
{
if
(
!
GetFullPathNameW
(
pwcsName
,
MAX_PATH
,
fullpath
,
NULL
))
{
lstrcpynW
(
fullpath
,
pwcsName
,
MAX_PATH
);
}
This
->
pwcsName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
fullpath
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
This
->
pwcsName
)
{
HeapFree
(
GetProcessHeap
(),
0
,
This
);
return
E_OUTOFMEMORY
;
}
strcpyW
(
This
->
pwcsName
,
fullpath
);
}
else
This
->
pwcsName
=
NULL
;
TRACE
(
"file len %u
\n
"
,
This
->
filesize
.
u
.
LowPart
);
*
pLockBytes
=
(
ILockBytes
*
)
This
;
...
...
@@ -145,6 +165,7 @@ static ULONG WINAPI FileLockBytesImpl_Release(ILockBytes *iface)
if
(
ref
==
0
)
{
CloseHandle
(
This
->
hfile
);
HeapFree
(
GetProcessHeap
(),
0
,
This
->
pwcsName
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
...
...
@@ -324,12 +345,16 @@ static HRESULT WINAPI FileLockBytesImpl_Stat(ILockBytes* iface,
{
FileLockBytesImpl
*
This
=
(
FileLockBytesImpl
*
)
iface
;
if
(
!
(
STATFLAG_NONAME
&
grfStatFlag
))
if
(
!
(
STATFLAG_NONAME
&
grfStatFlag
)
&&
This
->
pwcsName
)
{
FIXME
(
"reading filename not supported
\n
"
);
pstatstg
->
pwcsName
=
CoTaskMemAlloc
((
lstrlenW
(
This
->
pwcsName
)
+
1
)
*
sizeof
(
WCHAR
));
strcpyW
(
pstatstg
->
pwcsName
,
This
->
pwcsName
);
}
else
pstatstg
->
pwcsName
=
NULL
;
pstatstg
->
pwcsName
=
NULL
;
pstatstg
->
type
=
STGTY_LOCKBYTES
;
pstatstg
->
cbSize
=
This
->
filesize
;
/* FIXME: If the implementation is exported, we'll need to set other fields. */
...
...
dlls/ole32/storage32.c
View file @
d0e6e4aa
...
...
@@ -2583,6 +2583,19 @@ static HRESULT StorageImpl_StreamLink(StorageBaseImpl *base, DirRef dst,
return
hr
;
}
static
HRESULT
StorageImpl_GetFilename
(
StorageBaseImpl
*
iface
,
LPWSTR
*
result
)
{
StorageImpl
*
This
=
(
StorageImpl
*
)
iface
;
STATSTG
statstg
;
HRESULT
hr
;
hr
=
ILockBytes_Stat
(
This
->
lockBytes
,
&
statstg
,
0
);
*
result
=
statstg
.
pwcsName
;
return
hr
;
}
/*
* Virtual function table for the IStorage32Impl class.
*/
...
...
@@ -2612,6 +2625,7 @@ static const StorageBaseImplVtbl StorageImpl_BaseVtbl =
{
StorageImpl_Destroy
,
StorageImpl_Invalidate
,
StorageImpl_GetFilename
,
StorageImpl_CreateDirEntry
,
StorageImpl_BaseWriteDirEntry
,
StorageImpl_BaseReadDirEntry
,
...
...
@@ -2636,7 +2650,6 @@ static HRESULT StorageImpl_Construct(
HRESULT
hr
=
S_OK
;
DirEntry
currentEntry
;
DirRef
currentEntryRef
;
WCHAR
fullpath
[
MAX_PATH
];
if
(
FAILED
(
validateSTGM
(
openFlags
)
))
return
STG_E_INVALIDFLAG
;
...
...
@@ -2662,29 +2675,13 @@ static HRESULT StorageImpl_Construct(
This
->
hFile
=
hFile
;
if
(
pwcsName
)
{
if
(
!
GetFullPathNameW
(
pwcsName
,
MAX_PATH
,
fullpath
,
NULL
))
{
lstrcpynW
(
fullpath
,
pwcsName
,
MAX_PATH
);
}
This
->
pwcsName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
fullpath
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
This
->
pwcsName
)
{
hr
=
STG_E_INSUFFICIENTMEMORY
;
goto
end
;
}
strcpyW
(
This
->
pwcsName
,
fullpath
);
This
->
base
.
filename
=
This
->
pwcsName
;
}
/*
* Initialize the big block cache.
*/
This
->
bigBlockSize
=
sector_size
;
This
->
smallBlockSize
=
DEF_SMALL_BLOCK_SIZE
;
if
(
hFile
)
hr
=
FileLockBytesImpl_Construct
(
hFile
,
openFlags
,
&
This
->
lockBytes
);
hr
=
FileLockBytesImpl_Construct
(
hFile
,
openFlags
,
pwcsName
,
&
This
->
lockBytes
);
else
{
This
->
lockBytes
=
pLkbyt
;
...
...
@@ -2875,8 +2872,6 @@ static void StorageImpl_Destroy(StorageBaseImpl* iface)
StorageImpl_Invalidate
(
iface
);
HeapFree
(
GetProcessHeap
(),
0
,
This
->
pwcsName
);
BlockChainStream_Destroy
(
This
->
smallBlockRootChain
);
BlockChainStream_Destroy
(
This
->
rootBlockChain
);
BlockChainStream_Destroy
(
This
->
smallBlockDepotChain
);
...
...
@@ -4649,6 +4644,13 @@ static void TransactedSnapshotImpl_Destroy( StorageBaseImpl *iface)
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
static
HRESULT
TransactedSnapshotImpl_GetFilename
(
StorageBaseImpl
*
iface
,
LPWSTR
*
result
)
{
TransactedSnapshotImpl
*
This
=
(
TransactedSnapshotImpl
*
)
iface
;
return
StorageBaseImpl_GetFilename
(
This
->
transactedParent
,
result
);
}
static
HRESULT
TransactedSnapshotImpl_CreateDirEntry
(
StorageBaseImpl
*
base
,
const
DirEntry
*
newData
,
DirRef
*
index
)
{
...
...
@@ -4896,6 +4898,7 @@ static const StorageBaseImplVtbl TransactedSnapshotImpl_BaseVtbl =
{
TransactedSnapshotImpl_Destroy
,
TransactedSnapshotImpl_Invalidate
,
TransactedSnapshotImpl_GetFilename
,
TransactedSnapshotImpl_CreateDirEntry
,
TransactedSnapshotImpl_WriteDirEntry
,
TransactedSnapshotImpl_ReadDirEntry
,
...
...
@@ -4929,8 +4932,6 @@ static HRESULT TransactedSnapshotImpl_Construct(StorageBaseImpl *parentStorage,
(
*
result
)
->
base
.
openFlags
=
parentStorage
->
openFlags
;
(
*
result
)
->
base
.
filename
=
parentStorage
->
filename
;
/* Create a new temporary storage to act as the scratch file. */
hr
=
StgCreateDocfile
(
NULL
,
STGM_READWRITE
|
STGM_SHARE_EXCLUSIVE
|
STGM_CREATE
,
0
,
(
IStorage
**
)
&
(
*
result
)
->
scratch
);
...
...
@@ -5043,6 +5044,13 @@ static void StorageInternalImpl_Destroy( StorageBaseImpl *iface)
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
static
HRESULT
StorageInternalImpl_GetFilename
(
StorageBaseImpl
*
iface
,
LPWSTR
*
result
)
{
StorageInternalImpl
*
This
=
(
StorageInternalImpl
*
)
iface
;
return
StorageBaseImpl_GetFilename
(
This
->
parentStorage
,
result
);
}
static
HRESULT
StorageInternalImpl_CreateDirEntry
(
StorageBaseImpl
*
base
,
const
DirEntry
*
newData
,
DirRef
*
index
)
{
...
...
@@ -5468,6 +5476,7 @@ static const StorageBaseImplVtbl StorageInternalImpl_BaseVtbl =
{
StorageInternalImpl_Destroy
,
StorageInternalImpl_Invalidate
,
StorageInternalImpl_GetFilename
,
StorageInternalImpl_CreateDirEntry
,
StorageInternalImpl_WriteDirEntry
,
StorageInternalImpl_ReadDirEntry
,
...
...
@@ -5608,33 +5617,26 @@ void StorageUtl_CopyDirEntryToSTATSTG(
const
DirEntry
*
source
,
int
statFlags
)
{
LPCWSTR
entryName
;
if
(
source
->
stgType
==
STGTY_ROOT
)
{
/* replace the name of root entry (often "Root Entry") by the file name */
entryName
=
storage
->
filename
;
}
else
{
entryName
=
source
->
name
;
}
/*
* The copy of the string occurs only when the flag is not set
*/
if
(
((
statFlags
&
STATFLAG_NONAME
)
!=
0
)
||
(
entryName
==
NULL
)
||
(
entryName
[
0
]
==
0
)
)
if
(
!
(
statFlags
&
STATFLAG_NONAME
)
&&
source
->
stgType
==
STGTY_ROOT
)
{
/* Use the filename for the root storage. */
destination
->
pwcsName
=
0
;
StorageBaseImpl_GetFilename
(
storage
,
&
destination
->
pwcsName
);
}
else
if
(
((
statFlags
&
STATFLAG_NONAME
)
!=
0
)
||
(
source
->
name
[
0
]
==
0
)
)
{
destination
->
pwcsName
=
0
;
}
else
{
destination
->
pwcsName
=
CoTaskMemAlloc
((
lstrlenW
(
entryN
ame
)
+
1
)
*
sizeof
(
WCHAR
));
CoTaskMemAlloc
((
lstrlenW
(
source
->
n
ame
)
+
1
)
*
sizeof
(
WCHAR
));
strcpyW
(
destination
->
pwcsName
,
entryN
ame
);
strcpyW
(
destination
->
pwcsName
,
source
->
n
ame
);
}
switch
(
source
->
stgType
)
...
...
dlls/ole32/storage32.h
View file @
d0e6e4aa
...
...
@@ -154,7 +154,7 @@ struct DirEntry
ULARGE_INTEGER
size
;
};
HRESULT
FileLockBytesImpl_Construct
(
HANDLE
hFile
,
DWORD
openFlags
,
ILockBytes
**
pLockBytes
);
HRESULT
FileLockBytesImpl_Construct
(
HANDLE
hFile
,
DWORD
openFlags
,
LPCWSTR
pwcsName
,
ILockBytes
**
pLockBytes
);
/*************************************************************************
* Ole Convert support
...
...
@@ -221,9 +221,6 @@ struct StorageBaseImpl
*/
DWORD
stateBits
;
/* If set, this overrides the root storage name returned by IStorage_Stat */
LPCWSTR
filename
;
BOOL
create
;
/* Was the storage created or opened.
The behaviour of STGM_SIMPLE depends on this */
/*
...
...
@@ -237,6 +234,7 @@ struct StorageBaseImpl
struct
StorageBaseImplVtbl
{
void
(
*
Destroy
)(
StorageBaseImpl
*
);
void
(
*
Invalidate
)(
StorageBaseImpl
*
);
HRESULT
(
*
GetFilename
)(
StorageBaseImpl
*
,
LPWSTR
*
);
HRESULT
(
*
CreateDirEntry
)(
StorageBaseImpl
*
,
const
DirEntry
*
,
DirRef
*
);
HRESULT
(
*
WriteDirEntry
)(
StorageBaseImpl
*
,
DirRef
,
const
DirEntry
*
);
HRESULT
(
*
ReadDirEntry
)(
StorageBaseImpl
*
,
DirRef
,
DirEntry
*
);
...
...
@@ -257,6 +255,11 @@ static inline void StorageBaseImpl_Invalidate(StorageBaseImpl *This)
This
->
baseVtbl
->
Invalidate
(
This
);
}
static
inline
HRESULT
StorageBaseImpl_GetFilename
(
StorageBaseImpl
*
This
,
LPWSTR
*
result
)
{
return
This
->
baseVtbl
->
GetFilename
(
This
,
result
);
}
static
inline
HRESULT
StorageBaseImpl_CreateDirEntry
(
StorageBaseImpl
*
This
,
const
DirEntry
*
newData
,
DirRef
*
index
)
{
...
...
@@ -337,7 +340,6 @@ struct StorageImpl
* class
*/
HANDLE
hFile
;
/* Physical support for the Docfile */
LPOLESTR
pwcsName
;
/* Full path of the document file */
/*
* File header
...
...
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