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
63ef4c85
Commit
63ef4c85
authored
Jul 30, 2013
by
Piotr Caban
Committed by
Alexandre Julliard
Jul 30, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scrrun: Add IFileSystem3::CopyFile implementation.
parent
b1af25b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
2 deletions
+78
-2
filesystem.c
dlls/scrrun/filesystem.c
+78
-2
No files found.
dlls/scrrun/filesystem.c
View file @
63ef4c85
...
...
@@ -1505,12 +1505,88 @@ static HRESULT WINAPI filesys_MoveFolder(IFileSystem3 *iface,BSTR Source,
return
E_NOTIMPL
;
}
static
inline
HRESULT
copy_file
(
const
WCHAR
*
source
,
DWORD
source_len
,
const
WCHAR
*
destination
,
DWORD
destination_len
,
VARIANT_BOOL
overwrite
)
{
DWORD
attrs
;
WCHAR
src_path
[
MAX_PATH
],
dst_path
[
MAX_PATH
];
DWORD
src_len
,
dst_len
,
name_len
;
WIN32_FIND_DATAW
ffd
;
HANDLE
f
;
HRESULT
hr
;
if
(
!
source
[
0
]
||
!
destination
[
0
])
return
E_INVALIDARG
;
attrs
=
GetFileAttributesW
(
destination
);
if
(
attrs
==
INVALID_FILE_ATTRIBUTES
||
!
(
attrs
&
FILE_ATTRIBUTE_DIRECTORY
))
{
attrs
=
GetFileAttributesW
(
source
);
if
(
attrs
==
INVALID_FILE_ATTRIBUTES
)
return
create_error
(
GetLastError
());
else
if
(
attrs
&
FILE_ATTRIBUTE_DIRECTORY
)
return
CTL_E_FILENOTFOUND
;
if
(
!
CopyFileW
(
source
,
destination
,
!
overwrite
))
return
create_error
(
GetLastError
());
return
S_OK
;
}
f
=
FindFirstFileW
(
source
,
&
ffd
);
if
(
f
==
INVALID_HANDLE_VALUE
)
return
CTL_E_FILENOTFOUND
;
src_len
=
get_parent_folder_name
(
source
,
source_len
);
if
(
src_len
+
1
>=
MAX_PATH
)
return
E_FAIL
;
if
(
src_len
)
{
memcpy
(
src_path
,
source
,
src_len
*
sizeof
(
WCHAR
));
src_path
[
src_len
++
]
=
'\\'
;
}
dst_len
=
destination_len
;
if
(
dst_len
+
1
>=
MAX_PATH
)
return
E_FAIL
;
memcpy
(
dst_path
,
destination
,
dst_len
*
sizeof
(
WCHAR
));
if
(
dst_path
[
dst_len
-
1
]
!=
'\\'
&&
dst_path
[
dst_len
-
1
]
!=
'/'
)
dst_path
[
dst_len
++
]
=
'\\'
;
hr
=
CTL_E_FILENOTFOUND
;
do
{
if
(
ffd
.
dwFileAttributes
&
(
FILE_ATTRIBUTE_DIRECTORY
|
FILE_ATTRIBUTE_DEVICE
))
continue
;
name_len
=
strlenW
(
ffd
.
cFileName
);
if
(
src_len
+
name_len
+
1
>=
MAX_PATH
||
dst_len
+
name_len
+
1
>=
MAX_PATH
)
{
FindClose
(
f
);
return
E_FAIL
;
}
memcpy
(
src_path
+
src_len
,
ffd
.
cFileName
,
(
name_len
+
1
)
*
sizeof
(
WCHAR
));
memcpy
(
dst_path
+
dst_len
,
ffd
.
cFileName
,
(
name_len
+
1
)
*
sizeof
(
WCHAR
));
TRACE
(
"copying %s to %s
\n
"
,
debugstr_w
(
src_path
),
debugstr_w
(
dst_path
));
if
(
!
CopyFileW
(
src_path
,
dst_path
,
!
overwrite
))
{
FindClose
(
f
);
return
create_error
(
GetLastError
());
}
else
{
hr
=
S_OK
;
}
}
while
(
FindNextFileW
(
f
,
&
ffd
));
FindClose
(
f
);
return
hr
;
}
static
HRESULT
WINAPI
filesys_CopyFile
(
IFileSystem3
*
iface
,
BSTR
Source
,
BSTR
Destination
,
VARIANT_BOOL
OverWriteFiles
)
{
FIXM
E
(
"%p %s %s %d
\n
"
,
iface
,
debugstr_w
(
Source
),
debugstr_w
(
Destination
),
OverWriteFiles
);
TRAC
E
(
"%p %s %s %d
\n
"
,
iface
,
debugstr_w
(
Source
),
debugstr_w
(
Destination
),
OverWriteFiles
);
return
E_NOTIMPL
;
if
(
!
Source
||
!
Destination
)
return
E_POINTER
;
return
copy_file
(
Source
,
SysStringLen
(
Source
),
Destination
,
SysStringLen
(
Destination
),
OverWriteFiles
);
}
static
HRESULT
WINAPI
filesys_CopyFolder
(
IFileSystem3
*
iface
,
BSTR
Source
,
...
...
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