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
787633cf
Commit
787633cf
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 PathCchFindExtension.
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d36063d6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
161 additions
and
2 deletions
+161
-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
+34
-0
path.c
dlls/kernelbase/tests/path.c
+122
-0
pathcch.h
include/pathcch.h
+3
-0
No files found.
dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec
View file @
787633cf
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
@ stub PathCchCanonicalizeEx
@ stub PathCchCanonicalizeEx
@ stub PathCchCombine
@ stub PathCchCombine
@ stub PathCchCombineEx
@ stub PathCchCombineEx
@ st
ub
PathCchFindExtension
@ st
dcall PathCchFindExtension(wstr long ptr) kernelbase.
PathCchFindExtension
@ stub PathCchIsRoot
@ stub PathCchIsRoot
@ stub PathCchRemoveBackslash
@ stub PathCchRemoveBackslash
@ stub PathCchRemoveBackslashEx
@ stub PathCchRemoveBackslashEx
...
...
dlls/kernelbase/kernelbase.spec
View file @
787633cf
...
@@ -1038,7 +1038,7 @@
...
@@ -1038,7 +1038,7 @@
# @ stub PathCchCanonicalizeEx
# @ stub PathCchCanonicalizeEx
# @ stub PathCchCombine
# @ stub PathCchCombine
# @ stub PathCchCombineEx
# @ stub PathCchCombineEx
# @ stub PathCchFindExtension
@ stdcall PathCchFindExtension(wstr long ptr)
# @ stub PathCchIsRoot
# @ stub PathCchIsRoot
# @ stub PathCchRemoveBackslash
# @ stub PathCchRemoveBackslash
# @ stub PathCchRemoveBackslashEx
# @ stub PathCchRemoveBackslashEx
...
...
dlls/kernelbase/path.c
View file @
787633cf
/*
/*
* Copyright 2018 Nikolay Sivov
* Copyright 2018 Nikolay Sivov
* Copyright 2018 Zhiyi Zhang
*
*
* This library is free software; you can redistribute it and/or
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* modify it under the terms of the GNU Lesser General Public
...
@@ -65,3 +66,36 @@ HRESULT WINAPI PathCchAddBackslashEx(WCHAR *path, SIZE_T size, WCHAR **endptr, S
...
@@ -65,3 +66,36 @@ HRESULT WINAPI PathCchAddBackslashEx(WCHAR *path, SIZE_T size, WCHAR **endptr, S
return
S_OK
;
return
S_OK
;
}
}
HRESULT
WINAPI
PathCchFindExtension
(
const
WCHAR
*
path
,
SIZE_T
size
,
const
WCHAR
**
extension
)
{
const
WCHAR
*
lastpoint
=
NULL
;
SIZE_T
counter
=
0
;
TRACE
(
"%s %lu %p
\n
"
,
wine_dbgstr_w
(
path
),
size
,
extension
);
if
(
!
path
||
!
size
||
size
>
PATHCCH_MAX_CCH
)
{
*
extension
=
NULL
;
return
E_INVALIDARG
;
}
while
(
*
path
)
{
if
(
*
path
==
'\\'
||
*
path
==
' '
)
lastpoint
=
NULL
;
else
if
(
*
path
==
'.'
)
lastpoint
=
path
;
path
++
;
counter
++
;
if
(
counter
==
size
||
counter
==
PATHCCH_MAX_CCH
)
{
*
extension
=
NULL
;
return
E_INVALIDARG
;
}
}
*
extension
=
lastpoint
?
lastpoint
:
path
;
return
S_OK
;
}
dlls/kernelbase/tests/path.c
View file @
787633cf
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
* Path tests for kernelbase.dll
* Path tests for kernelbase.dll
*
*
* Copyright 2017 Michael Müller
* Copyright 2017 Michael Müller
* Copyright 2018 Zhiyi Zhang
*
*
* This library is free software; you can redistribute it and/or
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* modify it under the terms of the GNU Lesser General Public
...
@@ -32,6 +33,7 @@
...
@@ -32,6 +33,7 @@
HRESULT
(
WINAPI
*
pPathCchAddBackslash
)(
WCHAR
*
out
,
SIZE_T
size
);
HRESULT
(
WINAPI
*
pPathCchAddBackslash
)(
WCHAR
*
out
,
SIZE_T
size
);
HRESULT
(
WINAPI
*
pPathCchAddBackslashEx
)(
WCHAR
*
out
,
SIZE_T
size
,
WCHAR
**
endptr
,
SIZE_T
*
remaining
);
HRESULT
(
WINAPI
*
pPathCchAddBackslashEx
)(
WCHAR
*
out
,
SIZE_T
size
,
WCHAR
**
endptr
,
SIZE_T
*
remaining
);
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
);
static
const
struct
static
const
struct
{
{
...
@@ -245,6 +247,124 @@ static void test_PathCchAddBackslashEx(void)
...
@@ -245,6 +247,124 @@ static void test_PathCchAddBackslashEx(void)
}
}
}
}
struct
findextension_test
{
const
CHAR
*
path
;
INT
extension_offset
;
};
static
const
struct
findextension_test
findextension_tests
[]
=
{
/* Normal */
{
"1.exe"
,
1
},
{
"C:1.exe"
,
3
},
{
"C:
\\
1.exe"
,
4
},
{
"
\\
1.exe"
,
2
},
{
"
\\\\
1.exe"
,
3
},
{
"
\\\\
?
\\
C:1.exe"
,
7
},
{
"
\\\\
?
\\
C:
\\
1.exe"
,
8
},
{
"
\\\\
?
\\
UNC
\\
1.exe"
,
9
},
{
"
\\\\
?
\\
UNC
\\
192.168.1.1
\\
1.exe"
,
21
},
{
"
\\\\
?
\\
Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}
\\
1.exe"
,
50
},
/* Contains forward slash */
{
"C:
\\
a/1.exe"
,
6
},
{
"/1.exe"
,
2
},
{
"//1.exe"
,
3
},
{
"C:
\\
a/b/1.exe"
,
8
},
{
"/a/1.exe"
,
4
},
{
"/a/1.exe"
,
4
},
/* Malformed */
{
""
,
0
},
{
" "
,
1
},
{
"."
,
0
},
{
".."
,
1
},
{
"a"
,
1
},
{
"a."
,
1
},
{
".a.b."
,
4
},
{
"a. "
,
3
},
{
"a.
\\
"
,
3
},
{
"
\\\\
?
\\
UNC
\\
192.168.1.1"
,
17
},
{
"
\\\\
?
\\
UNC
\\
192.168.1.1
\\
"
,
20
},
{
"
\\\\
?
\\
UNC
\\
192.168.1.1
\\
a"
,
21
}
};
static
void
test_PathCchFindExtension
(
void
)
{
WCHAR
pathW
[
PATHCCH_MAX_CCH
+
1
]
=
{
0
};
const
WCHAR
*
extension
;
HRESULT
hr
;
INT
i
;
if
(
!
pPathCchFindExtension
)
{
win_skip
(
"PathCchFindExtension() is not available.
\n
"
);
return
;
}
/* Arguments check */
extension
=
(
const
WCHAR
*
)
0xdeadbeef
;
hr
=
pPathCchFindExtension
(
NULL
,
PATHCCH_MAX_CCH
,
&
extension
);
ok
(
hr
==
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
ok
(
extension
==
NULL
,
"Expect extension null, got %p
\n
"
,
extension
);
extension
=
(
const
WCHAR
*
)
0xdeadbeef
;
hr
=
pPathCchFindExtension
(
pathW
,
0
,
&
extension
);
ok
(
hr
==
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
ok
(
extension
==
NULL
,
"Expect extension null, got %p
\n
"
,
extension
);
/* Crashed on Windows */
if
(
0
)
{
hr
=
pPathCchFindExtension
(
pathW
,
PATHCCH_MAX_CCH
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
}
/* Path length check */
/* size == PATHCCH_MAX_CCH + 1 */
MultiByteToWideChar
(
CP_ACP
,
0
,
"C:
\\
1.exe"
,
-
1
,
pathW
,
ARRAY_SIZE
(
pathW
));
hr
=
pPathCchFindExtension
(
pathW
,
PATHCCH_MAX_CCH
+
1
,
&
extension
);
ok
(
hr
==
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
/* Size == path length + 1*/
hr
=
pPathCchFindExtension
(
pathW
,
ARRAY_SIZE
(
"C:
\\
1.exe"
),
&
extension
);
ok
(
hr
==
S_OK
,
"expect result %#x, got %#x
\n
"
,
S_OK
,
hr
);
ok
(
*
extension
==
'.'
,
"wrong extension value
\n
"
);
/* Size < path length + 1 */
extension
=
(
const
WCHAR
*
)
0xdeadbeef
;
hr
=
pPathCchFindExtension
(
pathW
,
ARRAY_SIZE
(
"C:
\\
1.exe"
)
-
1
,
&
extension
);
ok
(
hr
==
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
ok
(
extension
==
NULL
,
"Expect extension null, got %p
\n
"
,
extension
);
/* Size == PATHCCH_MAX_CCH */
hr
=
pPathCchFindExtension
(
pathW
,
PATHCCH_MAX_CCH
,
&
extension
);
ok
(
hr
==
S_OK
,
"expect result %#x, got %#x
\n
"
,
S_OK
,
hr
);
/* Path length + 1 > PATHCCH_MAX_CCH */
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
pathW
)
-
1
;
i
++
)
pathW
[
i
]
=
'a'
;
pathW
[
PATHCCH_MAX_CCH
]
=
0
;
hr
=
pPathCchFindExtension
(
pathW
,
PATHCCH_MAX_CCH
,
&
extension
);
ok
(
hr
==
E_INVALIDARG
,
"expect result %#x, got %#x
\n
"
,
E_INVALIDARG
,
hr
);
/* Path length + 1 == PATHCCH_MAX_CCH */
pathW
[
PATHCCH_MAX_CCH
-
1
]
=
0
;
hr
=
pPathCchFindExtension
(
pathW
,
PATHCCH_MAX_CCH
,
&
extension
);
ok
(
hr
==
S_OK
,
"expect result %#x, got %#x
\n
"
,
S_OK
,
hr
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
findextension_tests
);
i
++
)
{
const
struct
findextension_test
*
t
=
findextension_tests
+
i
;
MultiByteToWideChar
(
CP_ACP
,
0
,
t
->
path
,
-
1
,
pathW
,
ARRAY_SIZE
(
pathW
));
hr
=
pPathCchFindExtension
(
pathW
,
PATHCCH_MAX_CCH
,
&
extension
);
ok
(
hr
==
S_OK
,
"path %s expect result %#x, got %#x
\n
"
,
t
->
path
,
S_OK
,
hr
);
if
(
SUCCEEDED
(
hr
))
ok
(
extension
-
pathW
==
t
->
extension_offset
,
"path %s expect extension offset %d, got %ld
\n
"
,
t
->
path
,
t
->
extension_offset
,
(
UINT_PTR
)(
extension
-
pathW
));
}
}
START_TEST
(
path
)
START_TEST
(
path
)
{
{
HMODULE
hmod
=
LoadLibraryA
(
"kernelbase.dll"
);
HMODULE
hmod
=
LoadLibraryA
(
"kernelbase.dll"
);
...
@@ -252,8 +372,10 @@ START_TEST(path)
...
@@ -252,8 +372,10 @@ START_TEST(path)
pPathCchCombineEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchCombineEx"
);
pPathCchCombineEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchCombineEx"
);
pPathCchAddBackslash
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddBackslash"
);
pPathCchAddBackslash
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddBackslash"
);
pPathCchAddBackslashEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddBackslashEx"
);
pPathCchAddBackslashEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchAddBackslashEx"
);
pPathCchFindExtension
=
(
void
*
)
GetProcAddress
(
hmod
,
"PathCchFindExtension"
);
test_PathCchCombineEx
();
test_PathCchCombineEx
();
test_PathCchAddBackslash
();
test_PathCchAddBackslash
();
test_PathCchAddBackslashEx
();
test_PathCchAddBackslashEx
();
test_PathCchFindExtension
();
}
}
include/pathcch.h
View file @
787633cf
...
@@ -23,6 +23,9 @@
...
@@ -23,6 +23,9 @@
#define PATHCCH_DO_NOT_NORMALIZE_SEGMENTS 0x08
#define PATHCCH_DO_NOT_NORMALIZE_SEGMENTS 0x08
#define PATHCCH_ENSURE_IS_EXTENDED_LENGTH_PATH 0x10
#define PATHCCH_ENSURE_IS_EXTENDED_LENGTH_PATH 0x10
#define PATHCCH_MAX_CCH 0x8000
HRESULT
WINAPI
PathCchAddBackslash
(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
WINAPI
PathCchAddBackslash
(
WCHAR
*
path
,
SIZE_T
size
);
HRESULT
WINAPI
PathCchAddBackslashEx
(
WCHAR
*
path
,
SIZE_T
size
,
WCHAR
**
end
,
SIZE_T
*
remaining
);
HRESULT
WINAPI
PathCchAddBackslashEx
(
WCHAR
*
path
,
SIZE_T
size
,
WCHAR
**
end
,
SIZE_T
*
remaining
);
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
);
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