Skip to content

Commit 3d5cca6

Browse files
committed
WSL: use R2022b syntax as Windows machines typically have new-enough Matlab
1 parent 6357309 commit 3d5cca6

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

+stdlib/+sys/winpath2wslpath.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
function wsl_path = winpath2wslpath(win_path)
2-
3-
arguments
2+
%% winpath2wslpath convert native Windows path to WSL path
3+
arguments (Input)
44
win_path (1,1) string {mustBeNonzeroLengthText}
55
end
6+
arguments (Output)
7+
wsl_path (1,1) string {mustBeNonzeroLengthText}
8+
end
69

710
assert(stdlib.sys.has_wsl(), "stdlib:sys:winpath2wslpath:EnvironmentError", mfilename() + "only supported on Windows Matlab with WSL")
811

912
[stat, wsl_path] = system("wsl wslpath " + strrep(win_path, '\', '/'));
1013

1114
assert(stat == 0, "stdlib:sys:winpath2wslpath:IOError", "could not convert wslpath " + wsl_path)
1215

13-
wsl_path = strip(string(wsl_path));
16+
wsl_path = strip(wsl_path);
1417

1518
end

+stdlib/+sys/wsl_tempfile.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
function path = wsl_tempfile()
22
%% wsl_tempfile()
33
% Windows Subsystem for Linux (WSL) temporary file from Windows Matlab
4+
arguments (Output)
5+
path (1,1) string {mustBeNonzeroLengthText}
6+
end
47

58
assert(stdlib.sys.has_wsl(), "stdlib:sys:wsl_tempfile:EnvironmentError", mfilename() + "only supported on Windows Matlab with WSL")
69

710
[stat, path] = system("wsl mktemp -u");
811

912
assert(stat == 0, "stdlib:sys:wsl_tempfile:IOError", "could not get wsl mktemp " + path)
1013

11-
path = strip(string(path));
14+
path = strip(path);
1215

1316
end

+stdlib/+sys/wslpath2winpath.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
function win_path = wslpath2winpath(wsl_path)
22

3-
arguments
3+
arguments (Input)
44
wsl_path (1,1) string {mustBeNonzeroLengthText}
55
end
6+
arguments (Output)
7+
win_path (1,1) string {mustBeNonzeroLengthText}
8+
end
69

710
assert(stdlib.sys.has_wsl(), "stdlib:sys:wslpath2winpath:EnvironmentError", mfilename() + "only supported on Windows Matlab with WSL")
811

912
[stat, win_path] = system("wsl wslpath -w " + wsl_path);
1013

1114
assert(stat == 0, "stdlib:sys:wslpath2winpath:IOError", "could not convert wslpath " + win_path)
1215

13-
win_path = strip(string(win_path));
16+
win_path = strip(win_path);
1417

1518
end

+stdlib/winpath2wslpath.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
%% winpath2wslpath(win_path)
33
% Convert Windows path to WSL path
44
% input format like \\wsl$\Ubuntu\home\username\...
5-
arguments
5+
arguments (Input)
66
win_path (1,1) string {mustBeNonzeroLengthText}
77
end
8+
arguments (Output)
9+
wsl_path (1,1) string {mustBeNonzeroLengthText}
10+
end
811

912
wsl_path = stdlib.sys.winpath2wslpath(win_path);
1013

+stdlib/wslpath2winpath.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
%% wslpath2winpath(wsl_path)
33
% Convert a WSL path to a Windows path
44
% output format is like \\wsl$\Ubuntu\home\username\...
5-
arguments
5+
arguments (Input)
66
wsl_path (1,1) string {mustBeNonzeroLengthText}
77
end
8+
arguments (Output)
9+
win_path (1,1) string {mustBeNonzeroLengthText}
10+
end
811

912
win_path = stdlib.sys.wslpath2winpath(wsl_path);
1013

0 commit comments

Comments
 (0)