Skip to content

Commit b6da29b

Browse files
ivanwickmatthiasblaesing
authored andcommitted
Add Win32 API mapping for Shlwapi PathIsUNC
1 parent 333cc61 commit b6da29b

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Release 4.3.1 (Next release)
88
Features
99
--------
1010
* [#757](https://github.com/java-native-access/jna/issues/757): Build android archive (AAR) - [@matthiasblaesing](https://github.com/matthiasblaesing).
11+
* [#767](https://github.com/java-native-access/jna/pull/767): Add Win32 API mapping for Shlwapi PathIsUNC - [@ivanwick](https://github.com/ivanwick).
1112

1213
Bug Fixes
1314
---------

contrib/platform/src/com/sun/jna/platform/win32/Shlwapi.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,15 @@ public interface Shlwapi extends StdCallLibrary {
5555
*/
5656

5757
HRESULT StrRetToStr(PointerByReference pstr, Pointer pidl, PointerByReference ppszName);
58+
59+
/**
60+
* Determines if a path string is a valid Universal Naming Convention (UNC) path, as opposed to
61+
* a path based on a drive letter.
62+
*
63+
* @param path
64+
* A string containing the path to validate.
65+
*
66+
* @return TRUE if the string is a valid UNC path; otherwise, FALSE.
67+
*/
68+
boolean PathIsUNC(String path);
5869
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.sun.jna.platform.win32;
2+
3+
import junit.framework.TestCase;
4+
5+
public class ShlwapiTest extends TestCase {
6+
7+
public static void main(String[] args) {
8+
junit.textui.TestRunner.run(ShlwapiTest.class);
9+
}
10+
11+
public void testPathIsUNC() {
12+
assertEquals(true, Shlwapi.INSTANCE.PathIsUNC("\\\\path1\\path2"));
13+
assertEquals(true, Shlwapi.INSTANCE.PathIsUNC("\\\\path1"));
14+
assertEquals(false, Shlwapi.INSTANCE.PathIsUNC("acme\\\\path4\\\\path5"));
15+
assertEquals(true, Shlwapi.INSTANCE.PathIsUNC("\\\\"));
16+
assertEquals(true, Shlwapi.INSTANCE.PathIsUNC("\\\\?\\UNC\\path1\\path2"));
17+
assertEquals(true, Shlwapi.INSTANCE.PathIsUNC("\\\\?\\UNC\\path1"));
18+
assertEquals(true, Shlwapi.INSTANCE.PathIsUNC("\\\\?\\UNC\\"));
19+
assertEquals(false, Shlwapi.INSTANCE.PathIsUNC("\\path1"));
20+
assertEquals(false, Shlwapi.INSTANCE.PathIsUNC("path1"));
21+
assertEquals(false, Shlwapi.INSTANCE.PathIsUNC("c:\\path1"));
22+
assertEquals(false, Shlwapi.INSTANCE.PathIsUNC("\\\\?\\c:\\path1"));
23+
}
24+
}

0 commit comments

Comments
 (0)