Skip to content

Commit a764c81

Browse files
committed
add stdlib.fileio.is_wsl_path()
1 parent 74c0f98 commit a764c81

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

+stdlib/+fileio/is_wsl_path.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function iswsl = is_wsl_path(path)
2+
arguments
3+
path (1,1) string
4+
end
5+
6+
if ispc
7+
iswsl = any(startsWith(path, ["\\wsl$", "\\wsl.localhost"]));
8+
else
9+
iswsl = false;
10+
end
11+
12+
end

+stdlib/+test/TestWSL.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function test_wsl_path(tc)
4141
tc.verifyNotEmpty(wsl_temp, "could not get WSL tempfile")
4242

4343
wsl_path = stdlib.sys.wslpath2winpath(wsl_temp);
44-
tc.verifyNotEmpty(wsl_path, "could not convert WSL path to Windows path")
44+
tc.verifyTrue(stdlib.fileio.is_wsl_path(wsl_path), "could not convert WSL path to Windows path")
4545

4646
win_path = stdlib.sys.winpath2wslpath(wsl_path);
4747
tc.verifyNotEmpty(win_path, "could not convert Windows path to WSL path")
@@ -50,4 +50,4 @@ function test_wsl_path(tc)
5050

5151
end
5252

53-
end
53+
end

0 commit comments

Comments
 (0)