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
5d31184d
Commit
5d31184d
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 PathCchIsRoot.
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
2afa87bc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
2 deletions
+110
-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
+38
-0
path.c
dlls/kernelbase/tests/path.c
+69
-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 @
5d31184d
...
...
@@ -10,7 +10,7 @@
@ stub PathCchCombine
@ stub PathCchCombineEx
@ stdcall PathCchFindExtension(wstr long ptr) kernelbase.PathCchFindExtension
@ st
ub
PathCchIsRoot
@ st
dcall PathCchIsRoot(wstr) kernelbase.
PathCchIsRoot
@ stub PathCchRemoveBackslash
@ stub PathCchRemoveBackslashEx
@ stdcall PathCchRemoveExtension(wstr long) kernelbase.PathCchRemoveExtension
...
...
dlls/kernelbase/kernelbase.spec
View file @
5d31184d
...
...
@@ -1039,7 +1039,7 @@
# @ stub PathCchCombine
# @ stub PathCchCombineEx
@ stdcall PathCchFindExtension(wstr long ptr)
# @ stub PathCchIsRoot
@ stdcall PathCchIsRoot(wstr)
# @ stub PathCchRemoveBackslash
# @ stub PathCchRemoveBackslashEx
@ stdcall PathCchRemoveExtension(wstr long)
...
...
dlls/kernelbase/path.c
View file @
5d31184d
...
...
@@ -240,6 +240,44 @@ HRESULT WINAPI PathCchFindExtension(const WCHAR *path, SIZE_T size, const WCHAR
return
S_OK
;
}
BOOL
WINAPI
PathCchIsRoot
(
const
WCHAR
*
path
)
{
const
WCHAR
*
root_end
;
const
WCHAR
*
next
;
BOOL
is_unc
;
TRACE
(
"%s
\n
"
,
wine_dbgstr_w
(
path
));
if
(
!
path
||
!*
path
)
return
FALSE
;
root_end
=
get_root_end
(
path
);
if
(
!
root_end
)
return
FALSE
;
if
((
is_unc
=
is_prefixed_unc
(
path
))
||
(
path
[
0
]
==
'\\'
&&
path
[
1
]
==
'\\'
&&
path
[
2
]
!=
'?'
))
{
next
=
root_end
+
1
;
/* No extra segments */
if
((
is_unc
&&
!*
next
)
||
(
!
is_unc
&&
!*
next
))
return
TRUE
;
/* Has first segment with an ending backslash but no remaining characters */
if
(
get_next_segment
(
next
,
&
next
)
&&
!*
next
)
return
FALSE
;
/* Has first segment with no ending backslash */
else
if
(
!*
next
)
return
TRUE
;
/* Has first segment with an ending backslash and has remaining characters*/
else
{
next
++
;
/* Second segment must have no backslash and no remaining characters */
return
!
get_next_segment
(
next
,
&
next
)
&&
!*
next
;
}
}
else
if
(
*
root_end
==
'\\'
&&
!
root_end
[
1
])
return
TRUE
;
else
return
FALSE
;
}
HRESULT
WINAPI
PathCchRemoveExtension
(
WCHAR
*
path
,
SIZE_T
size
)
{
const
WCHAR
*
extension
;
...
...
dlls/kernelbase/tests/path.c
View file @
5d31184d
...
...
@@ -35,6 +35,7 @@ HRESULT (WINAPI *pPathCchAddBackslashEx)(WCHAR *out, SIZE_T size, WCHAR **endptr
HRESULT
(
WINAPI
*
pPathCchAddExtension
)(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
);
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
);
BOOL
(
WINAPI
*
pPathCchIsRoot
)(
const
WCHAR
*
path
);
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
);
...
...
@@ -477,6 +478,72 @@ static void test_PathCchFindExtension(void)
}
}
struct
isroot_test
{
const
CHAR
*
path
;
BOOL
ret
;
};
static
const
struct
isroot_test
isroot_tests
[]
=
{
{
""
,
FALSE
},
{
"a"
,
FALSE
},
{
"C:"
,
FALSE
},
{
"C:
\\
"
,
TRUE
},
{
"C:
\\
a"
,
FALSE
},
{
"
\\\\
?
\\
C:
\\
"
,
TRUE
},
{
"
\\\\
?
\\
C:"
,
FALSE
},
{
"
\\\\
?
\\
C:
\\
a"
,
FALSE
},
{
"
\\
"
,
TRUE
},
{
"
\\
a
\\
"
,
FALSE
},
{
"
\\
a
\\
b"
,
FALSE
},
{
"
\\\\
"
,
TRUE
},
{
"
\\\\
a"
,
TRUE
},
{
"
\\\\
a
\\
"
,
FALSE
},
{
"
\\\\
a
\\
b"
,
TRUE
},
{
"
\\\\
a
\\
b
\\
"
,
FALSE
},
{
"
\\\\
a
\\
b
\\
c"
,
FALSE
},
{
"
\\\\
?
\\
UNC
\\
"
,
TRUE
},
{
"
\\\\
?
\\
UNC
\\
a"
,
TRUE
},
{
"
\\\\
?
\\
UNC
\\
a
\\
"
,
FALSE
},
{
"
\\\\
?
\\
UNC
\\
a
\\
b"
,
TRUE
},
{
"
\\\\
?
\\
UNC
\\
a
\\
b
\\
"
,
FALSE
},
{
"
\\\\
?
\\
UNC
\\
a
\\
b
\\
c"
,
FALSE
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}"
,
FALSE
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
"
,
TRUE
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
a"
,
FALSE
},
{
"..
\\
a"
,
FALSE
},
/* Wrong MSDN examples */
{
"
\\
a"
,
FALSE
},
{
"X:"
,
FALSE
},
{
"
\\
server"
,
FALSE
}
};
static
void
test_PathCchIsRoot
(
void
)
{
WCHAR
pathW
[
MAX_PATH
];
BOOL
ret
;
INT
i
;
if
(
!
pPathCchIsRoot
)
{
win_skip
(
"PathCchIsRoot() is not available.
\n
"
);
return
;
}
ret
=
pPathCchIsRoot
(
NULL
);
ok
(
ret
==
FALSE
,
"expect return FALSE
\n
"
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
isroot_tests
);
i
++
)
{
const
struct
isroot_test
*
t
=
isroot_tests
+
i
;
MultiByteToWideChar
(
CP_ACP
,
0
,
t
->
path
,
-
1
,
pathW
,
ARRAY_SIZE
(
pathW
));
ret
=
pPathCchIsRoot
(
pathW
);
ok
(
ret
==
t
->
ret
,
"path %s expect return %d, got %d
\n
"
,
t
->
path
,
t
->
ret
,
ret
);
}
}
struct
removeextension_test
{
const
CHAR
*
path
;
...
...
@@ -1039,6 +1106,7 @@ START_TEST(path)
pPathCchAddBackslashEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddBackslashEx"
);
pPathCchAddExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddExtension"
);
pPathCchFindExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchFindExtension"
);
pPathCchIsRoot
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchIsRoot"
);
pPathCchRemoveExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchRemoveExtension"
);
pPathCchRenameExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchRenameExtension"
);
pPathCchSkipRoot
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchSkipRoot"
);
...
...
@@ -1051,6 +1119,7 @@ START_TEST(path)
test_PathCchAddBackslashEx
();
test_PathCchAddExtension
();
test_PathCchFindExtension
();
test_PathCchIsRoot
();
test_PathCchRemoveExtension
();
test_PathCchRenameExtension
();
test_PathCchSkipRoot
();
...
...
include/pathcch.h
View file @
5d31184d
...
...
@@ -30,6 +30,7 @@ HRESULT WINAPI PathCchAddBackslashEx(WCHAR *path, SIZE_T size, WCHAR **end, SIZE
HRESULT
WINAPI
PathCchAddExtension
(
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
*
extension
);
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
);
BOOL
WINAPI
PathCchIsRoot
(
const
WCHAR
*
path
);
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
);
...
...
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