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
b206287c
Commit
b206287c
authored
Aug 13, 2015
by
Vincent Povirk
Committed by
Alexandre Julliard
Aug 17, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comdlg32: Implement overwrite check in item dialog.
parent
3ec84397
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
1 deletion
+84
-1
itemdlg.c
dlls/comdlg32/itemdlg.c
+83
-0
itemdlg.c
dlls/comdlg32/tests/itemdlg.c
+1
-1
No files found.
dlls/comdlg32/itemdlg.c
View file @
b206287c
...
...
@@ -213,6 +213,47 @@ static void events_OnTypeChange(FileDialogImpl *This)
}
}
static
HRESULT
events_OnOverwrite
(
FileDialogImpl
*
This
,
IShellItem
*
shellitem
)
{
events_client
*
cursor
;
HRESULT
hr
=
S_OK
;
FDE_OVERWRITE_RESPONSE
response
=
FDEOR_DEFAULT
;
TRACE
(
"%p %p
\n
"
,
This
,
shellitem
);
LIST_FOR_EACH_ENTRY
(
cursor
,
&
This
->
events_clients
,
events_client
,
entry
)
{
TRACE
(
"Notifying %p
\n
"
,
cursor
);
hr
=
IFileDialogEvents_OnOverwrite
(
cursor
->
pfde
,
(
IFileDialog
*
)
&
This
->
IFileDialog2_iface
,
shellitem
,
&
response
);
TRACE
(
"<-- hr=%x response=%u
\n
"
,
hr
,
response
);
if
(
FAILED
(
hr
)
&&
hr
!=
E_NOTIMPL
)
break
;
}
if
(
hr
==
E_NOTIMPL
)
hr
=
S_OK
;
if
(
SUCCEEDED
(
hr
))
{
if
(
response
==
FDEOR_DEFAULT
)
{
WCHAR
buf
[
100
];
int
answer
;
LoadStringW
(
COMDLG32_hInstance
,
IDS_OVERWRITEFILE
,
buf
,
100
);
answer
=
MessageBoxW
(
This
->
dlg_hwnd
,
buf
,
This
->
custom_title
,
MB_YESNO
|
MB_ICONEXCLAMATION
);
if
(
answer
==
IDNO
||
answer
==
IDCANCEL
)
{
hr
=
E_FAIL
;
}
}
else
if
(
response
==
FDEOR_REFUSE
)
hr
=
E_FAIL
;
}
return
hr
;
}
static
inline
HRESULT
get_cctrl_event
(
IFileDialogEvents
*
pfde
,
IFileDialogControlEvents
**
pfdce
)
{
return
IFileDialogEvents_QueryInterface
(
pfde
,
&
IID_IFileDialogControlEvents
,
(
void
**
)
pfdce
);
...
...
@@ -423,6 +464,28 @@ static LPWSTR get_first_ext_from_spec(LPWSTR buf, LPCWSTR spec)
return
ext
;
}
static
BOOL
shell_item_exists
(
IShellItem
*
shellitem
)
{
LPWSTR
filename
;
HRESULT
hr
;
BOOL
result
;
hr
=
IShellItem_GetDisplayName
(
shellitem
,
SIGDN_FILESYSPATH
,
&
filename
);
if
(
SUCCEEDED
(
hr
))
{
/* FIXME: Implement SFGAO_VALIDATE in Wine and use it instead. */
result
=
(
GetFileAttributesW
(
filename
)
!=
INVALID_FILE_ATTRIBUTES
);
CoTaskMemFree
(
filename
);
}
else
{
SFGAOF
attributes
;
result
=
SUCCEEDED
(
IShellItem_GetAttributes
(
shellitem
,
SFGAO_VALIDATE
,
&
attributes
));
}
return
result
;
}
static
HRESULT
on_default_action
(
FileDialogImpl
*
This
)
{
IShellFolder
*
psf_parent
,
*
psf_desktop
;
...
...
@@ -589,6 +652,26 @@ static HRESULT on_default_action(FileDialogImpl *This)
}
}
if
((
This
->
options
&
FOS_OVERWRITEPROMPT
)
&&
This
->
dlg_type
==
ITEMDLG_TYPE_SAVE
)
{
IShellItem
*
shellitem
;
for
(
i
=
0
;
SUCCEEDED
(
hr
)
&&
i
<
file_count
;
i
++
)
{
hr
=
IShellItemArray_GetItemAt
(
This
->
psia_results
,
i
,
&
shellitem
);
if
(
SUCCEEDED
(
hr
))
{
if
(
shell_item_exists
(
shellitem
))
hr
=
events_OnOverwrite
(
This
,
shellitem
);
IShellItem_Release
(
shellitem
);
}
}
if
(
FAILED
(
hr
))
break
;
}
if
(
events_OnFileOk
(
This
)
==
S_OK
)
ret
=
S_OK
;
}
...
...
dlls/comdlg32/tests/itemdlg.c
View file @
b206287c
...
...
@@ -2370,7 +2370,7 @@ static void test_overwrite(void)
hr
=
IFileDialog_Show
(
fd
,
NULL
);
ok
(
hr
==
S_OK
,
"Show failed: Got 0x%08x
\n
"
,
hr
);
todo_wine
ok
(
pfdeimpl
->
OnOverwrite
==
1
,
"got %u overwrite events
\n
"
,
pfdeimpl
->
OnOverwrite
);
ok
(
pfdeimpl
->
OnOverwrite
==
1
,
"got %u overwrite events
\n
"
,
pfdeimpl
->
OnOverwrite
);
ok
(
pfdeimpl
->
OnFileOk
==
1
,
"got %u ok events
\n
"
,
pfdeimpl
->
OnFileOk
);
hr
=
IFileDialog_GetFileName
(
fd
,
&
filename
);
...
...
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