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
2ec414c8
Commit
2ec414c8
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 PathCchStripPrefix.
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c02419ed
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
2 deletions
+111
-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
+30
-0
path.c
dlls/kernelbase/tests/path.c
+78
-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 @
2ec414c8
...
...
@@ -17,6 +17,6 @@
@ stub PathCchRemoveFileSpec
@ stdcall PathCchRenameExtension(wstr long wstr) kernelbase.PathCchRenameExtension
@ stub PathCchSkipRoot
@ st
ub
PathCchStripPrefix
@ st
dcall PathCchStripPrefix(wstr long) kernelbase.
PathCchStripPrefix
@ stub PathCchStripToRoot
@ stdcall PathIsUNCEx(wstr ptr) kernelbase.PathIsUNCEx
dlls/kernelbase/kernelbase.spec
View file @
2ec414c8
...
...
@@ -1046,7 +1046,7 @@
# @ stub PathCchRemoveFileSpec
@ stdcall PathCchRenameExtension(wstr long wstr)
# @ stub PathCchSkipRoot
# @ stub PathCchStripPrefix
@ stdcall PathCchStripPrefix(wstr long)
# @ stub PathCchStripToRoot
@ stdcall PathCombineA(ptr str str) shlwapi.PathCombineA
@ stdcall PathCombineW(ptr wstr wstr) shlwapi.PathCombineW
...
...
dlls/kernelbase/path.c
View file @
2ec414c8
...
...
@@ -44,6 +44,12 @@ static BOOL is_prefixed_unc(const WCHAR *string)
return
!
strncmpiW
(
string
,
prefixed_unc
,
ARRAY_SIZE
(
prefixed_unc
));
}
static
BOOL
is_prefixed_disk
(
const
WCHAR
*
string
)
{
static
const
WCHAR
prefix
[]
=
{
'\\'
,
'\\'
,
'?'
,
'\\'
};
return
!
strncmpW
(
string
,
prefix
,
ARRAY_SIZE
(
prefix
))
&&
isalphaW
(
string
[
4
])
&&
string
[
5
]
==
':'
;
}
HRESULT
WINAPI
PathCchAddBackslash
(
WCHAR
*
path
,
SIZE_T
size
)
{
return
PathCchAddBackslashEx
(
path
,
size
,
NULL
,
NULL
);
...
...
@@ -190,6 +196,30 @@ HRESULT WINAPI PathCchRenameExtension(WCHAR *path, SIZE_T size, const WCHAR *ext
return
FAILED
(
hr
)
?
hr
:
S_OK
;
}
HRESULT
WINAPI
PathCchStripPrefix
(
WCHAR
*
path
,
SIZE_T
size
)
{
TRACE
(
"%s %lu
\n
"
,
wine_dbgstr_w
(
path
),
size
);
if
(
!
path
||
!
size
||
size
>
PATHCCH_MAX_CCH
)
return
E_INVALIDARG
;
if
(
is_prefixed_unc
(
path
))
{
/* \\?\UNC\a -> \\a */
if
(
size
<
strlenW
(
path
+
8
)
+
3
)
return
E_INVALIDARG
;
strcpyW
(
path
+
2
,
path
+
8
);
return
S_OK
;
}
else
if
(
is_prefixed_disk
(
path
))
{
/* \\?\C:\ -> C:\ */
if
(
size
<
strlenW
(
path
+
4
)
+
1
)
return
E_INVALIDARG
;
strcpyW
(
path
,
path
+
4
);
return
S_OK
;
}
else
return
S_FALSE
;
}
BOOL
WINAPI
PathIsUNCEx
(
const
WCHAR
*
path
,
const
WCHAR
**
server
)
{
const
WCHAR
*
result
=
NULL
;
...
...
dlls/kernelbase/tests/path.c
View file @
2ec414c8
...
...
@@ -37,6 +37,7 @@ HRESULT (WINAPI *pPathCchCombineEx)(WCHAR *out, SIZE_T size, const WCHAR *path1,
HRESULT
(
WINAPI
*
pPathCchFindExtension
)(
const
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
**
extension
);
HRESULT
(
WINAPI
*
pPathCchRemoveExtension
)(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
(
WINAPI
*
pPathCchRenameExtension
)(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
);
HRESULT
(
WINAPI
*
pPathCchStripPrefix
)(
WCHAR
*
path
,
SIZE_T
size
);
BOOL
(
WINAPI
*
pPathIsUNCEx
)(
const
WCHAR
*
path
,
const
WCHAR
**
server
);
static
const
struct
...
...
@@ -633,6 +634,81 @@ static void test_PathCchRenameExtension(void)
}
}
struct
stripprefix_test
{
const
CHAR
*
path
;
const
CHAR
*
stripped_path
;
HRESULT
hr
;
SIZE_T
size
;
};
static
const
struct
stripprefix_test
stripprefix_tests
[]
=
{
{
"
\\\\
?
\\
UNC
\\
"
,
"
\\\\
"
,
S_OK
},
{
"
\\\\
?
\\
UNC
\\
a"
,
"
\\\\
a"
,
S_OK
},
{
"
\\\\
?
\\
C:"
,
"C:"
,
S_OK
},
{
"
\\\\
?
\\
C:
\\
"
,
"C:
\\
"
,
S_OK
},
{
"
\\\\
?
\\
C:
\\
a"
,
"C:
\\
a"
,
S_OK
},
{
"
\\\\
?
\\
unc
\\
"
,
"
\\\\
"
,
S_OK
},
{
"
\\\\
?
\\
c:
\\
"
,
"c:
\\
"
,
S_OK
},
{
"
\\
"
,
"
\\
"
,
S_FALSE
},
{
"
\\\\
"
,
"
\\\\
"
,
S_FALSE
},
{
"
\\\\
a"
,
"
\\\\
a"
,
S_FALSE
},
{
"
\\\\
a
\\
"
,
"
\\\\
a
\\
"
,
S_FALSE
},
{
"
\\\\
?
\\
a"
,
"
\\\\
?
\\
a"
,
S_FALSE
},
{
"
\\\\
?
\\
UNC"
,
"
\\\\
?
\\
UNC"
,
S_FALSE
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
"
,
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
"
,
S_FALSE
},
/* Size Tests */
{
"C:
\\
"
,
NULL
,
E_INVALIDARG
,
PATHCCH_MAX_CCH
+
1
},
{
"C:
\\
"
,
"C:
\\
"
,
S_FALSE
,
PATHCCH_MAX_CCH
},
/* Size < original path actual length + 1, read beyond size */
{
"
\\\\
?
\\
C:
\\
"
,
"C:
\\
"
,
S_OK
,
ARRAY_SIZE
(
"
\\\\
?
\\
C:
\\
"
)
-
1
},
/* Size < stripped path length + 1 */
{
"
\\\\
?
\\
C:
\\
"
,
NULL
,
E_INVALIDARG
,
ARRAY_SIZE
(
"C:
\\
"
)
-
1
},
{
"
\\\\
?
\\
UNC
\\
"
,
NULL
,
E_INVALIDARG
,
ARRAY_SIZE
(
"
\\\\
"
)
-
1
}
};
static
void
test_PathCchStripPrefix
(
void
)
{
WCHAR
pathW
[
PATHCCH_MAX_CCH
+
1
]
=
{
0
};
CHAR
stripped_pathA
[
PATHCCH_MAX_CCH
];
SIZE_T
size
;
HRESULT
hr
;
INT
i
;
if
(
!
pPathCchStripPrefix
)
{
win_skip
(
"PathCchStripPrefix(() is not available.
\n
"
);
return
;
}
/* Null arguments */
hr
=
pPathCchStripPrefix
(
NULL
,
PATHCCH_MAX_CCH
);
ok
(
hr
==
E_INVALIDARG
,
"expect %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
hr
=
pPathCchStripPrefix
(
pathW
,
0
);
ok
(
hr
==
E_INVALIDARG
,
"expect %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
stripprefix_tests
);
i
++
)
{
const
struct
stripprefix_test
*
t
=
stripprefix_tests
+
i
;
MultiByteToWideChar
(
CP_ACP
,
0
,
t
->
path
,
-
1
,
pathW
,
ARRAY_SIZE
(
pathW
));
size
=
t
->
size
?
t
->
size
:
PATHCCH_MAX_CCH
;
hr
=
pPathCchStripPrefix
(
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
,
stripped_pathA
,
ARRAY_SIZE
(
stripped_pathA
),
NULL
,
NULL
);
ok
(
!
lstrcmpA
(
stripped_pathA
,
t
->
stripped_path
),
"path %s expect stripped path %s, got %s
\n
"
,
t
->
path
,
t
->
stripped_path
,
stripped_pathA
);
}
}
}
struct
isuncex_test
{
const
CHAR
*
path
;
...
...
@@ -713,6 +789,7 @@ START_TEST(path)
pPathCchFindExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchFindExtension"
);
pPathCchRemoveExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchRemoveExtension"
);
pPathCchRenameExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchRenameExtension"
);
pPathCchStripPrefix
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchStripPrefix"
);
pPathIsUNCEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathIsUNCEx"
);
test_PathCchCombineEx
();
...
...
@@ -722,5 +799,6 @@ START_TEST(path)
test_PathCchFindExtension
();
test_PathCchRemoveExtension
();
test_PathCchRenameExtension
();
test_PathCchStripPrefix
();
test_PathIsUNCEx
();
}
include/pathcch.h
View file @
2ec414c8
...
...
@@ -32,4 +32,5 @@ HRESULT WINAPI PathCchCombineEx(WCHAR *out, SIZE_T size, const WCHAR *path1, con
HRESULT
WINAPI
PathCchFindExtension
(
const
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
**
extension
);
HRESULT
WINAPI
PathCchRemoveExtension
(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
WINAPI
PathCchRenameExtension
(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
);
HRESULT
WINAPI
PathCchStripPrefix
(
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