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
5c23f335
Commit
5c23f335
authored
Nov 23, 2018
by
Zhiyi Zhang
Committed by
Alexandre Julliard
Nov 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Implement PathCchCanonicalize.
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
6c4b9111
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
2 deletions
+119
-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
+11
-0
path.c
dlls/kernelbase/tests/path.c
+105
-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 @
5c23f335
...
...
@@ -5,7 +5,7 @@
@ stdcall PathCchAddExtension(wstr long wstr) kernelbase.PathCchAddExtension
@ stub PathCchAppend
@ stub PathCchAppendEx
@ st
ub
PathCchCanonicalize
@ st
dcall PathCchCanonicalize(ptr long wstr) kernelbase.
PathCchCanonicalize
@ stdcall PathCchCanonicalizeEx(ptr long wstr long) kernelbase.PathCchCanonicalizeEx
@ stub PathCchCombine
@ stub PathCchCombineEx
...
...
dlls/kernelbase/kernelbase.spec
View file @
5c23f335
...
...
@@ -1034,7 +1034,7 @@
@ stdcall PathCchAddExtension(wstr long wstr)
# @ stub PathCchAppend
# @ stub PathCchAppendEx
# @ stub PathCchCanonicalize
@ stdcall PathCchCanonicalize(ptr long wstr)
@ stdcall PathCchCanonicalizeEx(ptr long wstr long)
# @ stub PathCchCombine
# @ stub PathCchCombineEx
...
...
dlls/kernelbase/path.c
View file @
5c23f335
...
...
@@ -389,6 +389,17 @@ HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extens
return
S_OK
;
}
HRESULT
WINAPI
PathCchCanonicalize
(
WCHAR
*
out
,
SIZE_T
size
,
const
WCHAR
*
in
)
{
TRACE
(
"%p %lu %s
\n
"
,
out
,
size
,
wine_dbgstr_w
(
in
));
/* Not X:\ and path > MAX_PATH - 4, return HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE) */
if
(
strlenW
(
in
)
>
MAX_PATH
-
4
&&
!
(
isalphaW
(
in
[
0
])
&&
in
[
1
]
==
':'
&&
in
[
2
]
==
'\\'
))
return
HRESULT_FROM_WIN32
(
ERROR_FILENAME_EXCED_RANGE
);
return
PathCchCanonicalizeEx
(
out
,
size
,
in
,
PATHCCH_NONE
);
}
HRESULT
WINAPI
PathCchCanonicalizeEx
(
WCHAR
*
out
,
SIZE_T
size
,
const
WCHAR
*
in
,
DWORD
flags
)
{
WCHAR
*
buffer
;
...
...
dlls/kernelbase/tests/path.c
View file @
5c23f335
...
...
@@ -34,6 +34,7 @@ HRESULT (WINAPI *pPathAllocCanonicalize)(const WCHAR *path_in, DWORD flags, WCHA
HRESULT
(
WINAPI
*
pPathCchAddBackslash
)(
WCHAR
*
out
,
SIZE_T
size
);
HRESULT
(
WINAPI
*
pPathCchAddBackslashEx
)(
WCHAR
*
out
,
SIZE_T
size
,
WCHAR
**
endptr
,
SIZE_T
*
remaining
);
HRESULT
(
WINAPI
*
pPathCchAddExtension
)(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
);
HRESULT
(
WINAPI
*
pPathCchCanonicalize
)(
WCHAR
*
out
,
SIZE_T
size
,
const
WCHAR
*
in
);
HRESULT
(
WINAPI
*
pPathCchCanonicalizeEx
)(
WCHAR
*
out
,
SIZE_T
size
,
const
WCHAR
*
in
,
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
);
...
...
@@ -668,6 +669,108 @@ static void test_PathCchAddExtension(void)
}
}
static
void
test_PathCchCanonicalize
(
void
)
{
WCHAR
path_inW
[
MAX_PATH
],
path_outW
[
MAX_PATH
];
CHAR
path_outA
[
MAX_PATH
];
HRESULT
hr
;
INT
i
;
if
(
!
pPathCchCanonicalize
)
{
win_skip
(
"PathCchCanonicalize() is not available.
\n
"
);
return
;
}
/* No NULL check for path pointers on Windows */
if
(
0
)
{
hr
=
pPathCchCanonicalize
(
NULL
,
ARRAY_SIZE
(
path_outW
),
path_inW
);
ok
(
hr
==
E_INVALIDARG
,
"expect hr %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
/* MSDN says NULL path_in result in a backslash added to path_out, but the fact is that it would crash */
hr
=
pPathCchCanonicalize
(
path_outW
,
ARRAY_SIZE
(
path_outW
),
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"expect hr %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
}
hr
=
pPathCchCanonicalize
(
path_outW
,
0
,
path_inW
);
ok
(
hr
==
E_INVALIDARG
,
"expect hr %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
/* Test path length */
for
(
i
=
0
;
i
<
MAX_PATH
-
3
;
i
++
)
path_inW
[
i
]
=
'a'
;
path_inW
[
MAX_PATH
-
3
]
=
'\0'
;
memset
(
path_outW
,
0
,
sizeof
(
path_outW
));
hr
=
pPathCchCanonicalize
(
path_outW
,
ARRAY_SIZE
(
path_outW
),
path_inW
);
ok
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_FILENAME_EXCED_RANGE
),
"expect hr %#x, got %#x %s
\n
"
,
HRESULT_FROM_WIN32
(
ERROR_FILENAME_EXCED_RANGE
),
hr
,
wine_dbgstr_w
(
path_outW
));
ok
(
lstrlenW
(
path_outW
)
==
0
,
"got %d
\n
"
,
lstrlenW
(
path_outW
));
path_inW
[
0
]
=
'C'
;
path_inW
[
1
]
=
':'
;
path_inW
[
2
]
=
'\\'
;
hr
=
pPathCchCanonicalize
(
path_outW
,
ARRAY_SIZE
(
path_outW
),
path_inW
);
ok
(
hr
==
S_OK
,
"expect hr %#x, got %#x
\n
"
,
S_OK
,
hr
);
path_inW
[
MAX_PATH
-
4
]
=
'\0'
;
hr
=
pPathCchCanonicalize
(
path_outW
,
ARRAY_SIZE
(
path_outW
),
path_inW
);
ok
(
hr
==
S_OK
,
"expect hr %#x, got %#x
\n
"
,
S_OK
,
hr
);
/* Insufficient buffer size handling */
hr
=
pPathCchCanonicalize
(
path_outW
,
1
,
path_inW
);
ok
(
hr
==
STRSAFE_E_INSUFFICIENT_BUFFER
,
"expect hr %#x, got %#x
\n
"
,
STRSAFE_E_INSUFFICIENT_BUFFER
,
hr
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
alloccanonicalize_tests
);
i
++
)
{
const
struct
alloccanonicalize_test
*
t
=
alloccanonicalize_tests
+
i
;
/* Skip testing X: path input, this case is different compared to PathAllocCanonicalize */
/* Skip test cases where a flag is used */
if
(
!
lstrcmpA
(
"C:"
,
t
->
path_in
)
||
t
->
flags
)
continue
;
MultiByteToWideChar
(
CP_ACP
,
0
,
t
->
path_in
,
-
1
,
path_inW
,
ARRAY_SIZE
(
path_inW
));
hr
=
pPathCchCanonicalize
(
path_outW
,
ARRAY_SIZE
(
path_outW
),
path_inW
);
ok
(
hr
==
t
->
hr
,
"path %s expect result %#x, got %#x
\n
"
,
t
->
path_in
,
t
->
hr
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
WideCharToMultiByte
(
CP_ACP
,
0
,
path_outW
,
-
1
,
path_outA
,
ARRAY_SIZE
(
path_outA
),
NULL
,
NULL
);
ok
(
!
lstrcmpA
(
path_outA
,
t
->
path_out
),
"path
\"
%s
\"
expect output path
\"
%s
\"
, got
\"
%s
\"\n
"
,
t
->
path_in
,
t
->
path_out
,
path_outA
);
}
}
/* X: path input */
/* Fill a \ at the end of X: if there is enough space */
MultiByteToWideChar
(
CP_ACP
,
0
,
"C:"
,
-
1
,
path_inW
,
ARRAY_SIZE
(
path_inW
));
hr
=
pPathCchCanonicalize
(
path_outW
,
ARRAY_SIZE
(
path_outW
),
path_inW
);
ok
(
hr
==
S_OK
,
"path %s expect result %#x, got %#x
\n
"
,
"C:"
,
S_OK
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
WideCharToMultiByte
(
CP_ACP
,
0
,
path_outW
,
-
1
,
path_outA
,
ARRAY_SIZE
(
path_outA
),
NULL
,
NULL
);
ok
(
!
lstrcmpA
(
path_outA
,
"C:
\\
"
),
"path
\"
%s
\"
expect output path
\"
%s
\"
, got
\"
%s
\"\n
"
,
"C:"
,
"C:
\\
"
,
path_outA
);
}
/* Don't fill a \ at the end of X: if there isn't enough space */
MultiByteToWideChar
(
CP_ACP
,
0
,
"C:"
,
-
1
,
path_inW
,
ARRAY_SIZE
(
path_inW
));
hr
=
pPathCchCanonicalize
(
path_outW
,
3
,
path_inW
);
ok
(
hr
==
S_OK
,
"path %s expect result %#x, got %#x
\n
"
,
"C:"
,
S_OK
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
WideCharToMultiByte
(
CP_ACP
,
0
,
path_outW
,
-
1
,
path_outA
,
ARRAY_SIZE
(
path_outA
),
NULL
,
NULL
);
ok
(
!
lstrcmpA
(
path_outA
,
"C:"
),
"path
\"
%s
\"
expect output path
\"
%s
\"
, got
\"
%s
\"\n
"
,
"C:"
,
"C:
\\
"
,
path_outA
);
}
/* Don't fill a \ at the end of X: if there is character following X: */
MultiByteToWideChar
(
CP_ACP
,
0
,
"C:a"
,
-
1
,
path_inW
,
ARRAY_SIZE
(
path_inW
));
hr
=
pPathCchCanonicalize
(
path_outW
,
ARRAY_SIZE
(
path_outW
),
path_inW
);
ok
(
hr
==
S_OK
,
"path %s expect result %#x, got %#x
\n
"
,
"C:a"
,
S_OK
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
WideCharToMultiByte
(
CP_ACP
,
0
,
path_outW
,
-
1
,
path_outA
,
ARRAY_SIZE
(
path_outA
),
NULL
,
NULL
);
ok
(
!
lstrcmpA
(
path_outA
,
"C:a"
),
"path
\"
%s
\"
expect output path
\"
%s
\"
, got
\"
%s
\"\n
"
,
"C:a"
,
"C:a"
,
path_outA
);
}
}
static
void
test_PathCchCanonicalizeEx
(
void
)
{
WCHAR
path_inW
[
PATHCCH_MAX_CCH
+
1
],
path_outW
[
PATHCCH_MAX_CCH
];
...
...
@@ -1836,6 +1939,7 @@ START_TEST(path)
pPathCchAddBackslash
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddBackslash"
);
pPathCchAddBackslashEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddBackslashEx"
);
pPathCchAddExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddExtension"
);
pPathCchCanonicalize
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchCanonicalize"
);
pPathCchCanonicalizeEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchCanonicalizeEx"
);
pPathCchFindExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchFindExtension"
);
pPathCchIsRoot
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchIsRoot"
);
...
...
@@ -1854,6 +1958,7 @@ START_TEST(path)
test_PathCchAddBackslash
();
test_PathCchAddBackslashEx
();
test_PathCchAddExtension
();
test_PathCchCanonicalize
();
test_PathCchCanonicalizeEx
();
test_PathCchFindExtension
();
test_PathCchIsRoot
();
...
...
include/pathcch.h
View file @
5c23f335
...
...
@@ -30,6 +30,7 @@ HRESULT WINAPI PathAllocCanonicalize(const WCHAR *path_in, DWORD flags, WCHAR **
HRESULT
WINAPI
PathCchAddBackslash
(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
WINAPI
PathCchAddBackslashEx
(
WCHAR
*
path
,
SIZE_T
size
,
WCHAR
**
end
,
SIZE_T
*
remaining
);
HRESULT
WINAPI
PathCchAddExtension
(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
);
HRESULT
WINAPI
PathCchCanonicalize
(
WCHAR
*
out
,
SIZE_T
size
,
const
WCHAR
*
in
);
HRESULT
WINAPI
PathCchCanonicalizeEx
(
WCHAR
*
out
,
SIZE_T
size
,
const
WCHAR
*
in
,
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
);
...
...
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