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
55bcfea8
Commit
55bcfea8
authored
Nov 20, 2018
by
Zhiyi Zhang
Committed by
Alexandre Julliard
Nov 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Implement PathCchRenameExtension.
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
43b5e4ba
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
2 deletions
+96
-2
api-ms-win-core-path-l1-1-0.spec
...-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec
+1
-1
kernelbase.spec
dlls/kernelbase/kernelbase.spec
+1
-1
path.c
dlls/kernelbase/path.c
+13
-0
path.c
dlls/kernelbase/tests/path.c
+80
-0
pathcch.h
include/pathcch.h
+1
-0
No files found.
dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec
View file @
55bcfea8
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
@ stub PathCchRemoveBackslashEx
@ stub PathCchRemoveBackslashEx
@ stdcall PathCchRemoveExtension(wstr long) kernelbase.PathCchRemoveExtension
@ stdcall PathCchRemoveExtension(wstr long) kernelbase.PathCchRemoveExtension
@ stub PathCchRemoveFileSpec
@ stub PathCchRemoveFileSpec
@ st
ub
PathCchRenameExtension
@ st
dcall PathCchRenameExtension(wstr long wstr) kernelbase.
PathCchRenameExtension
@ stub PathCchSkipRoot
@ stub PathCchSkipRoot
@ stub PathCchStripPrefix
@ stub PathCchStripPrefix
@ stub PathCchStripToRoot
@ stub PathCchStripToRoot
...
...
dlls/kernelbase/kernelbase.spec
View file @
55bcfea8
...
@@ -1044,7 +1044,7 @@
...
@@ -1044,7 +1044,7 @@
# @ stub PathCchRemoveBackslashEx
# @ stub PathCchRemoveBackslashEx
@ stdcall PathCchRemoveExtension(wstr long)
@ stdcall PathCchRemoveExtension(wstr long)
# @ stub PathCchRemoveFileSpec
# @ stub PathCchRemoveFileSpec
# @ stub PathCchRenameExtension
@ stdcall PathCchRenameExtension(wstr long wstr)
# @ stub PathCchSkipRoot
# @ stub PathCchSkipRoot
# @ stub PathCchStripPrefix
# @ stub PathCchStripPrefix
# @ stub PathCchStripToRoot
# @ stub PathCchStripToRoot
...
...
dlls/kernelbase/path.c
View file @
55bcfea8
...
@@ -170,3 +170,16 @@ HRESULT WINAPI PathCchRemoveExtension(WCHAR *path, SIZE_T size)
...
@@ -170,3 +170,16 @@ HRESULT WINAPI PathCchRemoveExtension(WCHAR *path, SIZE_T size)
return
next
==
extension
?
S_FALSE
:
S_OK
;
return
next
==
extension
?
S_FALSE
:
S_OK
;
}
}
HRESULT
WINAPI
PathCchRenameExtension
(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
)
{
HRESULT
hr
;
TRACE
(
"%s %lu %s
\n
"
,
wine_dbgstr_w
(
path
),
size
,
wine_dbgstr_w
(
extension
));
hr
=
PathCchRemoveExtension
(
path
,
size
);
if
(
FAILED
(
hr
))
return
hr
;
hr
=
PathCchAddExtension
(
path
,
size
,
extension
);
return
FAILED
(
hr
)
?
hr
:
S_OK
;
}
dlls/kernelbase/tests/path.c
View file @
55bcfea8
...
@@ -36,6 +36,7 @@ HRESULT (WINAPI *pPathCchAddExtension)(WCHAR *path, SIZE_T size, const WCHAR *ex
...
@@ -36,6 +36,7 @@ HRESULT (WINAPI *pPathCchAddExtension)(WCHAR *path, SIZE_T size, const WCHAR *ex
HRESULT
(
WINAPI
*
pPathCchCombineEx
)(
WCHAR
*
out
,
SIZE_T
size
,
const
WCHAR
*
path1
,
const
WCHAR
*
path2
,
DWORD
flags
);
HRESULT
(
WINAPI
*
pPathCchCombineEx
)(
WCHAR
*
out
,
SIZE_T
size
,
const
WCHAR
*
path1
,
const
WCHAR
*
path2
,
DWORD
flags
);
HRESULT
(
WINAPI
*
pPathCchFindExtension
)(
const
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
**
extension
);
HRESULT
(
WINAPI
*
pPathCchFindExtension
)(
const
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
**
extension
);
HRESULT
(
WINAPI
*
pPathCchRemoveExtension
)(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
(
WINAPI
*
pPathCchRemoveExtension
)(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
(
WINAPI
*
pPathCchRenameExtension
)(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
);
static
const
struct
static
const
struct
{
{
...
@@ -554,6 +555,83 @@ static void test_PathCchRemoveExtension(void)
...
@@ -554,6 +555,83 @@ static void test_PathCchRemoveExtension(void)
}
}
}
}
struct
renameextension_test
{
const
CHAR
*
path
;
const
CHAR
*
extension
;
const
CHAR
*
expected
;
};
static
const
struct
renameextension_test
renameextension_tests
[]
=
{
{
"1.exe"
,
".txt"
,
"1.txt"
},
{
"C:1.exe"
,
".txt"
,
"C:1.txt"
},
{
"C:
\\
1.exe"
,
".txt"
,
"C:
\\
1.txt"
},
{
"
\\
1.exe"
,
".txt"
,
"
\\
1.txt"
},
{
"
\\\\
1.exe"
,
".txt"
,
"
\\\\
1.txt"
},
{
"
\\\\
?
\\
C:1.exe"
,
".txt"
,
"
\\\\
?
\\
C:1.txt"
},
{
"
\\\\
?
\\
C:
\\
1.exe"
,
".txt"
,
"
\\\\
?
\\
C:
\\
1.txt"
},
{
"
\\\\
?
\\
UNC
\\
1.exe"
,
".txt"
,
"
\\\\
?
\\
UNC
\\
1.txt"
},
{
"
\\\\
?
\\
UNC
\\
192.168.1.1
\\
1.exe"
,
".txt"
,
"
\\\\
?
\\
UNC
\\
192.168.1.1
\\
1.txt"
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
1.exe"
,
".txt"
,
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
1.txt"
},
{
"C:
\\
1.exe"
,
""
,
"C:
\\
1"
},
{
"C:
\\
1.exe"
,
"txt"
,
"C:
\\
1.txt"
}
};
static
void
test_PathCchRenameExtension
(
void
)
{
WCHAR
pathW
[
PATHCCH_MAX_CCH
+
1
];
CHAR
pathA
[
PATHCCH_MAX_CCH
+
1
];
WCHAR
extensionW
[
MAX_PATH
];
HRESULT
hr
;
INT
i
;
if
(
!
pPathCchRenameExtension
)
{
win_skip
(
"PathCchRenameExtension() is not available.
\n
"
);
return
;
}
/* Invalid arguments */
MultiByteToWideChar
(
CP_ACP
,
0
,
"C:
\\
1.txt"
,
-
1
,
pathW
,
ARRAY_SIZE
(
pathW
));
MultiByteToWideChar
(
CP_ACP
,
0
,
".exe"
,
-
1
,
extensionW
,
ARRAY_SIZE
(
extensionW
));
hr
=
pPathCchRenameExtension
(
NULL
,
PATHCCH_MAX_CCH
,
extensionW
);
ok
(
hr
==
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
hr
=
pPathCchRenameExtension
(
pathW
,
0
,
extensionW
);
ok
(
hr
==
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
hr
=
pPathCchRenameExtension
(
pathW
,
PATHCCH_MAX_CCH
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
/* Path length */
hr
=
pPathCchRenameExtension
(
pathW
,
ARRAY_SIZE
(
"C:
\\
1.exe"
)
-
1
,
extensionW
);
ok
(
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
hr
=
pPathCchRenameExtension
(
pathW
,
PATHCCH_MAX_CCH
+
1
,
extensionW
);
ok
(
hr
==
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
hr
=
pPathCchRenameExtension
(
pathW
,
PATHCCH_MAX_CCH
,
extensionW
);
ok
(
hr
==
S_OK
,
"expect result %#x, got %#x
\n
"
,
S_OK
,
hr
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
renameextension_tests
);
i
++
)
{
const
struct
renameextension_test
*
t
=
renameextension_tests
+
i
;
MultiByteToWideChar
(
CP_ACP
,
0
,
t
->
path
,
-
1
,
pathW
,
ARRAY_SIZE
(
pathW
));
MultiByteToWideChar
(
CP_ACP
,
0
,
t
->
extension
,
-
1
,
extensionW
,
ARRAY_SIZE
(
extensionW
));
hr
=
pPathCchRenameExtension
(
pathW
,
PATHCCH_MAX_CCH
,
extensionW
);
ok
(
hr
==
S_OK
,
"path %s extension %s expect result %#x, got %#x
\n
"
,
t
->
path
,
t
->
extension
,
S_OK
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
WideCharToMultiByte
(
CP_ACP
,
0
,
pathW
,
-
1
,
pathA
,
ARRAY_SIZE
(
pathA
),
NULL
,
NULL
);
ok
(
!
lstrcmpA
(
pathA
,
t
->
expected
),
"path %s extension %s expect output path %s, got %s
\n
"
,
t
->
path
,
t
->
extension
,
t
->
expected
,
pathA
);
}
}
}
START_TEST
(
path
)
START_TEST
(
path
)
{
{
HMODULE
hmod
=
LoadLibraryA
(
"kernelbase.dll"
);
HMODULE
hmod
=
LoadLibraryA
(
"kernelbase.dll"
);
...
@@ -564,6 +642,7 @@ START_TEST(path)
...
@@ -564,6 +642,7 @@ START_TEST(path)
pPathCchAddExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddExtension"
);
pPathCchAddExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddExtension"
);
pPathCchFindExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchFindExtension"
);
pPathCchFindExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchFindExtension"
);
pPathCchRemoveExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchRemoveExtension"
);
pPathCchRemoveExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchRemoveExtension"
);
pPathCchRenameExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchRenameExtension"
);
test_PathCchCombineEx
();
test_PathCchCombineEx
();
test_PathCchAddBackslash
();
test_PathCchAddBackslash
();
...
@@ -571,4 +650,5 @@ START_TEST(path)
...
@@ -571,4 +650,5 @@ START_TEST(path)
test_PathCchAddExtension
();
test_PathCchAddExtension
();
test_PathCchFindExtension
();
test_PathCchFindExtension
();
test_PathCchRemoveExtension
();
test_PathCchRemoveExtension
();
test_PathCchRenameExtension
();
}
}
include/pathcch.h
View file @
55bcfea8
...
@@ -31,3 +31,4 @@ HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extens
...
@@ -31,3 +31,4 @@ HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extens
HRESULT
WINAPI
PathCchCombineEx
(
WCHAR
*
out
,
SIZE_T
size
,
const
WCHAR
*
path1
,
const
WCHAR
*
path2
,
DWORD
flags
);
HRESULT
WINAPI
PathCchCombineEx
(
WCHAR
*
out
,
SIZE_T
size
,
const
WCHAR
*
path1
,
const
WCHAR
*
path2
,
DWORD
flags
);
HRESULT
WINAPI
PathCchFindExtension
(
const
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
**
extension
);
HRESULT
WINAPI
PathCchFindExtension
(
const
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
**
extension
);
HRESULT
WINAPI
PathCchRemoveExtension
(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
WINAPI
PathCchRemoveExtension
(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
WINAPI
PathCchRenameExtension
(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
);
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