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
2afa87bc
Commit
2afa87bc
authored
Nov 22, 2018
by
Zhiyi Zhang
Committed by
Alexandre Julliard
Nov 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Implement PathCchStripToRoot.
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
03d19f3e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
170 additions
and
2 deletions
+170
-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
+39
-0
path.c
dlls/kernelbase/tests/path.c
+128
-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 @
2afa87bc
...
...
@@ -18,5 +18,5 @@
@ stdcall PathCchRenameExtension(wstr long wstr) kernelbase.PathCchRenameExtension
@ stdcall PathCchSkipRoot(wstr ptr) kernelbase.PathCchSkipRoot
@ stdcall PathCchStripPrefix(wstr long) kernelbase.PathCchStripPrefix
@ st
ub
PathCchStripToRoot
@ st
dcall PathCchStripToRoot(wstr long) kernelbase.
PathCchStripToRoot
@ stdcall PathIsUNCEx(wstr ptr) kernelbase.PathIsUNCEx
dlls/kernelbase/kernelbase.spec
View file @
2afa87bc
...
...
@@ -1047,7 +1047,7 @@
@ stdcall PathCchRenameExtension(wstr long wstr)
@ stdcall PathCchSkipRoot(wstr ptr)
@ stdcall PathCchStripPrefix(wstr long)
# @ stub PathCchStripToRoot
@ stdcall PathCchStripToRoot(wstr long)
@ stdcall PathCombineA(ptr str str) shlwapi.PathCombineA
@ stdcall PathCombineW(ptr wstr wstr) shlwapi.PathCombineW
@ stdcall PathCommonPrefixA(str str ptr) shlwapi.PathCommonPrefixA
...
...
dlls/kernelbase/path.c
View file @
2afa87bc
...
...
@@ -328,6 +328,45 @@ HRESULT WINAPI PathCchStripPrefix(WCHAR *path, SIZE_T size)
return
S_FALSE
;
}
HRESULT
WINAPI
PathCchStripToRoot
(
WCHAR
*
path
,
SIZE_T
size
)
{
const
WCHAR
*
root_end
;
WCHAR
*
segment_end
;
BOOL
is_unc
;
TRACE
(
"%s %lu
\n
"
,
wine_dbgstr_w
(
path
),
size
);
if
(
!
path
||
!*
path
||
!
size
||
size
>
PATHCCH_MAX_CCH
)
return
E_INVALIDARG
;
/* \\\\?\\UNC\\* and \\\\* have to have at least two extra segments to be striped,
* e.g. \\\\?\\UNC\\a\\b\\c -> \\\\?\\UNC\\a\\b
* \\\\a\\b\\c -> \\\\a\\b */
if
((
is_unc
=
is_prefixed_unc
(
path
))
||
(
path
[
0
]
==
'\\'
&&
path
[
1
]
==
'\\'
&&
path
[
2
]
!=
'?'
))
{
root_end
=
is_unc
?
path
+
8
:
path
+
3
;
if
(
!
get_next_segment
(
root_end
,
&
root_end
))
return
S_FALSE
;
if
(
!
get_next_segment
(
root_end
,
&
root_end
))
return
S_FALSE
;
if
(
root_end
-
path
>=
size
)
return
E_INVALIDARG
;
segment_end
=
path
+
(
root_end
-
path
)
-
1
;
*
segment_end
=
0
;
return
S_OK
;
}
else
if
(
PathCchSkipRoot
(
path
,
&
root_end
)
==
S_OK
)
{
if
(
root_end
-
path
>=
size
)
return
E_INVALIDARG
;
segment_end
=
path
+
(
root_end
-
path
);
if
(
!*
segment_end
)
return
S_FALSE
;
*
segment_end
=
0
;
return
S_OK
;
}
else
return
E_INVALIDARG
;
}
BOOL
WINAPI
PathIsUNCEx
(
const
WCHAR
*
path
,
const
WCHAR
**
server
)
{
const
WCHAR
*
result
=
NULL
;
...
...
dlls/kernelbase/tests/path.c
View file @
2afa87bc
...
...
@@ -39,6 +39,7 @@ HRESULT (WINAPI *pPathCchRemoveExtension)(WCHAR *path, SIZE_T size);
HRESULT
(
WINAPI
*
pPathCchRenameExtension
)(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
);
HRESULT
(
WINAPI
*
pPathCchSkipRoot
)(
const
WCHAR
*
path
,
const
WCHAR
**
root_end
);
HRESULT
(
WINAPI
*
pPathCchStripPrefix
)(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
(
WINAPI
*
pPathCchStripToRoot
)(
WCHAR
*
path
,
SIZE_T
size
);
BOOL
(
WINAPI
*
pPathIsUNCEx
)(
const
WCHAR
*
path
,
const
WCHAR
**
server
);
static
const
struct
...
...
@@ -835,6 +836,131 @@ static void test_PathCchStripPrefix(void)
}
}
struct
striptoroot_test
{
const
CHAR
*
path
;
const
CHAR
*
root
;
HRESULT
hr
;
SIZE_T
size
;
};
static
const
struct
striptoroot_test
striptoroot_tests
[]
=
{
/* Invalid */
{
""
,
""
,
E_INVALIDARG
},
{
"C"
,
NULL
,
E_INVALIDARG
},
{
"
\\\\
?
\\
UNC"
,
NULL
,
E_INVALIDARG
},
/* Size */
{
"C:
\\
"
,
NULL
,
E_INVALIDARG
,
PATHCCH_MAX_CCH
+
1
},
{
"C:
\\
"
,
"C:
\\
"
,
S_FALSE
,
PATHCCH_MAX_CCH
},
/* Size < original path length + 1, read beyond size */
{
"C:
\\
a"
,
"C:
\\
"
,
S_OK
,
ARRAY_SIZE
(
"C:
\\
a"
)
-
1
},
/* Size < stripped path length + 1 */
{
"C:
\\
a"
,
"C:
\\
"
,
E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},
/* Prefixed X: */
{
"
\\\\
?
\\
C:"
,
"
\\\\
?
\\
C:"
,
S_FALSE
},
{
"
\\\\
?
\\
C:a"
,
"
\\\\
?
\\
C:"
,
S_OK
},
{
"
\\\\
?
\\
C:a
\\
b"
,
"
\\\\
?
\\
C:"
,
S_OK
},
{
"
\\\\
?
\\
C:a
\\
b
\\
c"
,
"
\\\\
?
\\
C:"
,
S_OK
},
/* Prefixed X:\ */
{
"
\\\\
?
\\
C:
\\
"
,
"
\\\\
?
\\
C:
\\
"
,
S_FALSE
},
{
"
\\\\
?
\\
C:
\\
a"
,
"
\\\\
?
\\
C:
\\
"
,
S_OK
},
{
"
\\\\
?
\\
C:
\\
a
\\
b"
,
"
\\\\
?
\\
C:
\\
"
,
S_OK
},
{
"
\\\\
?
\\
C:
\\
a
\\
b
\\
c"
,
"
\\\\
?
\\
C:
\\
"
,
S_OK
},
/* UNC Volume */
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}"
,
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}"
,
S_FALSE
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}a"
,
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}"
,
S_OK
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}a
\\
b"
,
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}"
,
S_OK
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}a
\\
b
\\
c"
,
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}"
,
S_OK
},
/* UNC Volume with backslash */
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
"
,
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
"
,
S_FALSE
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
a"
,
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
"
,
S_OK
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
a
\\
b"
,
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
"
,
S_OK
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
a
\\
b
\\
c"
,
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
"
,
S_OK
},
};
static
void
test_PathCchStripToRoot
(
void
)
{
WCHAR
pathW
[
PATHCCH_MAX_CCH
];
CHAR
rootA
[
PATHCCH_MAX_CCH
];
SIZE_T
size
;
HRESULT
hr
;
INT
i
;
if
(
!
pPathCchStripToRoot
)
{
win_skip
(
"PathCchStripToRoot() is not available.
\n
"
);
return
;
}
/* Null arguments */
hr
=
pPathCchStripToRoot
(
NULL
,
ARRAY_SIZE
(
pathW
));
ok
(
hr
==
E_INVALIDARG
,
"Expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
MultiByteToWideChar
(
CP_ACP
,
0
,
"C:
\\
a"
,
-
1
,
pathW
,
ARRAY_SIZE
(
pathW
));
hr
=
pPathCchStripToRoot
(
pathW
,
0
);
ok
(
hr
==
E_INVALIDARG
,
"Expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
striptoroot_tests
);
i
++
)
{
const
struct
striptoroot_test
*
t
=
striptoroot_tests
+
i
;
MultiByteToWideChar
(
CP_ACP
,
0
,
t
->
path
,
-
1
,
pathW
,
ARRAY_SIZE
(
pathW
));
size
=
t
->
size
?
t
->
size
:
ARRAY_SIZE
(
pathW
);
hr
=
pPathCchStripToRoot
(
pathW
,
size
);
ok
(
hr
==
t
->
hr
,
"path %s expect result %#x, got %#x
\n
"
,
t
->
path
,
t
->
hr
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
WideCharToMultiByte
(
CP_ACP
,
0
,
pathW
,
-
1
,
rootA
,
ARRAY_SIZE
(
rootA
),
NULL
,
NULL
);
ok
(
!
lstrcmpA
(
rootA
,
t
->
root
),
"path %s expect stripped path %s, got %s
\n
"
,
t
->
path
,
t
->
root
,
rootA
);
}
}
}
struct
isuncex_test
{
const
CHAR
*
path
;
...
...
@@ -917,6 +1043,7 @@ START_TEST(path)
pPathCchRenameExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchRenameExtension"
);
pPathCchSkipRoot
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchSkipRoot"
);
pPathCchStripPrefix
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchStripPrefix"
);
pPathCchStripToRoot
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchStripToRoot"
);
pPathIsUNCEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathIsUNCEx"
);
test_PathCchCombineEx
();
...
...
@@ -928,5 +1055,6 @@ START_TEST(path)
test_PathCchRenameExtension
();
test_PathCchSkipRoot
();
test_PathCchStripPrefix
();
test_PathCchStripToRoot
();
test_PathIsUNCEx
();
}
include/pathcch.h
View file @
2afa87bc
...
...
@@ -34,4 +34,5 @@ HRESULT WINAPI PathCchRemoveExtension(WCHAR *path, SIZE_T size);
HRESULT
WINAPI
PathCchRenameExtension
(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
);
HRESULT
WINAPI
PathCchSkipRoot
(
const
WCHAR
*
path
,
const
WCHAR
**
root_end
);
HRESULT
WINAPI
PathCchStripPrefix
(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
WINAPI
PathCchStripToRoot
(
WCHAR
*
path
,
SIZE_T
size
);
BOOL
WINAPI
PathIsUNCEx
(
const
WCHAR
*
path
,
const
WCHAR
**
server
);
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