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
7a4225c6
Commit
7a4225c6
authored
Nov 10, 2012
by
Nikolay Sivov
Committed by
Alexandre Julliard
Nov 12, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scrrun: Block stream reading calls if it's not in ForReading mode.
parent
49a8d4ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
22 deletions
+129
-22
filesystem.c
dlls/scrrun/filesystem.c
+30
-2
filesystem.c
dlls/scrrun/tests/filesystem.c
+99
-20
No files found.
dlls/scrrun/filesystem.c
View file @
7a4225c6
...
...
@@ -41,6 +41,13 @@ struct folder {
struct
textstream
{
ITextStream
ITextStream_iface
;
LONG
ref
;
IOMode
mode
;
};
enum
iotype
{
IORead
,
IOWrite
};
static
inline
struct
folder
*
impl_from_IFolder
(
IFolder
*
iface
)
...
...
@@ -53,6 +60,14 @@ static inline struct textstream *impl_from_ITextStream(ITextStream *iface)
return
CONTAINING_RECORD
(
iface
,
struct
textstream
,
ITextStream_iface
);
}
static
int
textstream_check_iomode
(
struct
textstream
*
This
,
enum
iotype
type
)
{
if
(
type
==
IORead
)
return
This
->
mode
==
ForWriting
||
This
->
mode
==
ForAppending
;
else
return
1
;
}
static
HRESULT
WINAPI
textstream_QueryInterface
(
ITextStream
*
iface
,
REFIID
riid
,
void
**
obj
)
{
struct
textstream
*
This
=
impl_from_ITextStream
(
iface
);
...
...
@@ -183,6 +198,10 @@ static HRESULT WINAPI textstream_Read(ITextStream *iface, LONG len, BSTR *text)
{
struct
textstream
*
This
=
impl_from_ITextStream
(
iface
);
FIXME
(
"(%p)->(%p): stub
\n
"
,
This
,
text
);
if
(
textstream_check_iomode
(
This
,
IORead
))
return
CTL_E_BADFILEMODE
;
return
E_NOTIMPL
;
}
...
...
@@ -190,6 +209,10 @@ static HRESULT WINAPI textstream_ReadLine(ITextStream *iface, BSTR *text)
{
struct
textstream
*
This
=
impl_from_ITextStream
(
iface
);
FIXME
(
"(%p)->(%p): stub
\n
"
,
This
,
text
);
if
(
textstream_check_iomode
(
This
,
IORead
))
return
CTL_E_BADFILEMODE
;
return
E_NOTIMPL
;
}
...
...
@@ -197,6 +220,10 @@ static HRESULT WINAPI textstream_ReadAll(ITextStream *iface, BSTR *text)
{
struct
textstream
*
This
=
impl_from_ITextStream
(
iface
);
FIXME
(
"(%p)->(%p): stub
\n
"
,
This
,
text
);
if
(
textstream_check_iomode
(
This
,
IORead
))
return
CTL_E_BADFILEMODE
;
return
E_NOTIMPL
;
}
...
...
@@ -265,7 +292,7 @@ static const ITextStreamVtbl textstreamvtbl = {
textstream_Close
};
static
HRESULT
create_textstream
(
ITextStream
**
ret
)
static
HRESULT
create_textstream
(
I
OMode
mode
,
I
TextStream
**
ret
)
{
struct
textstream
*
stream
;
...
...
@@ -274,6 +301,7 @@ static HRESULT create_textstream(ITextStream **ret)
stream
->
ITextStream_iface
.
lpVtbl
=
&
textstreamvtbl
;
stream
->
ref
=
1
;
stream
->
mode
=
mode
;
*
ret
=
&
stream
->
ITextStream_iface
;
return
S_OK
;
...
...
@@ -892,7 +920,7 @@ static HRESULT WINAPI filesys_OpenTextFile(IFileSystem3 *iface, BSTR filename,
Tristate
format
,
ITextStream
**
stream
)
{
FIXME
(
"(%p)->(%s %d %d %d %p)
\n
"
,
iface
,
debugstr_w
(
filename
),
mode
,
create
,
format
,
stream
);
return
create_textstream
(
stream
);
return
create_textstream
(
mode
,
stream
);
}
static
HRESULT
WINAPI
filesys_GetStandardStream
(
IFileSystem3
*
iface
,
...
...
dlls/scrrun/tests/filesystem.c
View file @
7a4225c6
...
...
@@ -31,6 +31,8 @@
#include "initguid.h"
#include "scrrun.h"
static
IFileSystem3
*
fs3
;
static
void
test_interfaces
(
void
)
{
static
const
WCHAR
nonexistent_dirW
[]
=
{
...
...
@@ -41,27 +43,18 @@ static void test_interfaces(void)
HRESULT
hr
;
IDispatch
*
disp
;
IDispatchEx
*
dispex
;
IFileSystem3
*
fs3
;
IObjectWithSite
*
site
;
VARIANT_BOOL
b
;
BSTR
path
;
WCHAR
windows_path
[
MAX_PATH
];
WCHAR
file_path
[
MAX_PATH
];
hr
=
CoCreateInstance
(
&
CLSID_FileSystemObject
,
NULL
,
CLSCTX_INPROC_SERVER
|
CLSCTX_INPROC_HANDLER
,
&
IID_IDispatch
,
(
void
**
)
&
disp
);
if
(
FAILED
(
hr
))
{
win_skip
(
"Could not create FileSystem object: %08x
\n
"
,
hr
);
return
;
}
IFileSystem3_QueryInterface
(
fs3
,
&
IID_IDispatch
,
(
void
**
)
&
disp
);
GetSystemDirectoryW
(
windows_path
,
MAX_PATH
);
lstrcpyW
(
file_path
,
windows_path
);
lstrcatW
(
file_path
,
file_kernel32W
);
hr
=
IDispatch_QueryInterface
(
disp
,
&
IID_IFileSystem3
,
(
void
**
)
&
fs3
);
ok
(
hr
==
S_OK
,
"got 0x%08x, expected 0x%08x
\n
"
,
hr
,
S_OK
);
hr
=
IDispatch_QueryInterface
(
disp
,
&
IID_IObjectWithSite
,
(
void
**
)
&
site
);
ok
(
hr
==
E_NOINTERFACE
,
"got 0x%08x, expected 0x%08x
\n
"
,
hr
,
E_NOINTERFACE
);
...
...
@@ -119,25 +112,16 @@ static void test_interfaces(void)
ok
(
b
==
VARIANT_FALSE
,
"Folder exists
\n
"
);
SysFreeString
(
path
);
IFileSystem3_Release
(
fs3
);
IDispatch_Release
(
disp
);
}
static
void
test_createfolder
(
void
)
{
IFileSystem3
*
fs3
;
HRESULT
hr
;
WCHAR
pathW
[
MAX_PATH
];
BSTR
path
;
IFolder
*
folder
;
hr
=
CoCreateInstance
(
&
CLSID_FileSystemObject
,
NULL
,
CLSCTX_INPROC_SERVER
|
CLSCTX_INPROC_HANDLER
,
&
IID_IFileSystem3
,
(
void
**
)
&
fs3
);
if
(
FAILED
(
hr
))
{
win_skip
(
"Could not create FileSystem object: %08x
\n
"
,
hr
);
return
;
}
/* create existing directory */
GetCurrentDirectoryW
(
sizeof
(
pathW
)
/
sizeof
(
WCHAR
),
pathW
);
path
=
SysAllocString
(
pathW
);
...
...
@@ -146,16 +130,111 @@ static void test_createfolder(void)
ok
(
hr
==
CTL_E_FILEALREADYEXISTS
,
"got 0x%08x
\n
"
,
hr
);
ok
(
folder
==
NULL
,
"got %p
\n
"
,
folder
);
SysFreeString
(
path
);
}
IFileSystem3_Release
(
fs3
);
static
void
test_textstream
(
void
)
{
static
WCHAR
testfileW
[]
=
{
't'
,
'e'
,
's'
,
't'
,
'f'
,
'i'
,
'l'
,
'e'
,
'.'
,
't'
,
'x'
,
't'
,
0
};
ITextStream
*
stream
;
VARIANT_BOOL
b
;
HANDLE
file
;
HRESULT
hr
;
BSTR
name
,
data
;
file
=
CreateFileW
(
testfileW
,
GENERIC_READ
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
CloseHandle
(
file
);
name
=
SysAllocString
(
testfileW
);
b
=
VARIANT_FALSE
;
hr
=
IFileSystem3_FileExists
(
fs3
,
name
,
&
b
);
ok
(
hr
==
S_OK
,
"got 0x%08x, expected 0x%08x
\n
"
,
hr
,
S_OK
);
ok
(
b
==
VARIANT_TRUE
,
"got %x
\n
"
,
b
);
hr
=
IFileSystem3_OpenTextFile
(
fs3
,
name
,
ForReading
,
VARIANT_FALSE
,
TristateFalse
,
&
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
b
=
10
;
hr
=
ITextStream_get_AtEndOfStream
(
stream
,
&
b
);
todo_wine
{
ok
(
hr
==
S_FALSE
||
broken
(
hr
==
S_OK
),
"got 0x%08x
\n
"
,
hr
);
ok
(
b
==
VARIANT_TRUE
,
"got 0x%x
\n
"
,
b
);
}
ITextStream_Release
(
stream
);
hr
=
IFileSystem3_OpenTextFile
(
fs3
,
name
,
ForWriting
,
VARIANT_FALSE
,
TristateFalse
,
&
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
b
=
10
;
hr
=
ITextStream_get_AtEndOfStream
(
stream
,
&
b
);
todo_wine
{
ok
(
hr
==
CTL_E_BADFILEMODE
,
"got 0x%08x
\n
"
,
hr
);
ok
(
b
==
VARIANT_TRUE
||
broken
(
b
==
10
),
"got 0x%x
\n
"
,
b
);
}
b
=
10
;
hr
=
ITextStream_get_AtEndOfLine
(
stream
,
&
b
);
todo_wine
{
ok
(
hr
==
CTL_E_BADFILEMODE
,
"got 0x%08x
\n
"
,
hr
);
ok
(
b
==
VARIANT_FALSE
||
broken
(
b
==
10
),
"got 0x%x
\n
"
,
b
);
}
hr
=
ITextStream_Read
(
stream
,
1
,
&
data
);
ok
(
hr
==
CTL_E_BADFILEMODE
,
"got 0x%08x
\n
"
,
hr
);
hr
=
ITextStream_ReadLine
(
stream
,
&
data
);
ok
(
hr
==
CTL_E_BADFILEMODE
,
"got 0x%08x
\n
"
,
hr
);
hr
=
ITextStream_ReadAll
(
stream
,
&
data
);
ok
(
hr
==
CTL_E_BADFILEMODE
,
"got 0x%08x
\n
"
,
hr
);
ITextStream_Release
(
stream
);
hr
=
IFileSystem3_OpenTextFile
(
fs3
,
name
,
ForAppending
,
VARIANT_FALSE
,
TristateFalse
,
&
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
SysFreeString
(
name
);
b
=
10
;
hr
=
ITextStream_get_AtEndOfStream
(
stream
,
&
b
);
todo_wine
{
ok
(
hr
==
CTL_E_BADFILEMODE
,
"got 0x%08x
\n
"
,
hr
);
ok
(
b
==
VARIANT_TRUE
||
broken
(
b
==
10
),
"got 0x%x
\n
"
,
b
);
}
b
=
10
;
hr
=
ITextStream_get_AtEndOfLine
(
stream
,
&
b
);
todo_wine
{
ok
(
hr
==
CTL_E_BADFILEMODE
,
"got 0x%08x
\n
"
,
hr
);
ok
(
b
==
VARIANT_FALSE
||
broken
(
b
==
10
),
"got 0x%x
\n
"
,
b
);
}
hr
=
ITextStream_Read
(
stream
,
1
,
&
data
);
ok
(
hr
==
CTL_E_BADFILEMODE
,
"got 0x%08x
\n
"
,
hr
);
hr
=
ITextStream_ReadLine
(
stream
,
&
data
);
ok
(
hr
==
CTL_E_BADFILEMODE
,
"got 0x%08x
\n
"
,
hr
);
hr
=
ITextStream_ReadAll
(
stream
,
&
data
);
ok
(
hr
==
CTL_E_BADFILEMODE
,
"got 0x%08x
\n
"
,
hr
);
ITextStream_Release
(
stream
);
DeleteFileW
(
testfileW
);
}
START_TEST
(
filesystem
)
{
HRESULT
hr
;
CoInitialize
(
NULL
);
hr
=
CoCreateInstance
(
&
CLSID_FileSystemObject
,
NULL
,
CLSCTX_INPROC_SERVER
|
CLSCTX_INPROC_HANDLER
,
&
IID_IFileSystem3
,
(
void
**
)
&
fs3
);
if
(
FAILED
(
hr
))
{
win_skip
(
"Could not create FileSystem object: %08x
\n
"
,
hr
);
return
;
}
test_interfaces
();
test_createfolder
();
test_textstream
();
IFileSystem3_Release
(
fs3
);
CoUninitialize
();
}
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