Skip to content

Commit 74adb3a

Browse files
committed
Matlab < R2022b improved compaitiblity
1 parent 39cd334 commit 74adb3a

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

+stdlib/device.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
%% DEVICE filesystem device index of path
22

3-
function i = device(path)
3+
function i = device(p)
44
arguments
5-
path {mustBeTextScalar}
5+
p {mustBeTextScalar}
66
end
77

88
i = [];
99

1010
if stdlib.has_python()
11-
i = uint64(py.pathlib.Path(path).stat().st_dev);
11+
i = uint64(int64(py.os.stat(p).st_dev)); % int64 first is for Matlab <= R2022a
1212
elseif ispc() && stdlib.has_dotnet()
13-
i = device_dotnet(path);
13+
i = device_dotnet(p);
1414
elseif stdlib.isoctave()
15-
[s, err] = stat(path);
15+
[s, err] = stat(p);
1616
if err == 0
1717
i = s.dev;
1818
end
1919
elseif isunix() && stdlib.java_api() >= 11
2020
% Java 1.8 is buggy in some corner cases, so we require at least 11.
2121
opt = javaMethod("values", "java.nio.file.LinkOption");
22-
i = java.nio.file.Files.getAttribute(javaPathObject(path), "unix:dev", opt);
22+
i = java.nio.file.Files.getAttribute(javaPathObject(p), "unix:dev", opt);
2323
end
2424

2525
end

+stdlib/disk_available.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
if stdlib.has_python()
1616
di = py.shutil.disk_usage(d);
17-
f = uint64(di.free);
17+
f = uint64(int64(di.free)); % int64 first is for Matlab <= R2022a
1818
elseif stdlib.has_dotnet()
1919
f = System.IO.DriveInfo(stdlib.absolute(d)).AvailableFreeSpace();
2020
% https://learn.microsoft.com/en-us/dotnet/api/system.io.driveinfo.availablefreespace

+stdlib/disk_capacity.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
if stdlib.has_python()
1414
di = py.shutil.disk_usage(d);
15-
f = uint64(di.total);
15+
f = uint64(int64(di.total)); % int64 first is for Matlab <= R2022a
1616
elseif stdlib.has_dotnet()
1717
f = System.IO.DriveInfo(stdlib.absolute(d)).TotalSize();
1818
% https://learn.microsoft.com/en-us/dotnet/api/system.io.driveinfo.totalsize

+stdlib/hard_link_count.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
c = [];
1414

1515
if stdlib.has_python()
16-
c = uint64(py.pathlib.Path(p).stat().st_nlink);
16+
c = uint64(int64(py.os.stat(p).st_nlink)); % int64 first is for Matlab <= R2022a
1717
elseif stdlib.isoctave()
1818
[s, err] = stat(p);
1919
if err == 0

+stdlib/has_python.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
try
88
pe = pyenv();
9-
y = ~isempty(pe.Version);
9+
y = strlength(pe.Version) > 0;
1010
catch
1111
y = false;
1212
end

+stdlib/inode.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
%
33
% Windows always returns 0, Unix returns inode number.
44

5-
function i = inode(path)
5+
function i = inode(p)
66
arguments
7-
path {mustBeTextScalar}
7+
p {mustBeTextScalar}
88
end
99

1010
i = [];
1111

1212
if stdlib.has_python()
13-
i = uint64(py.pathlib.Path(path).stat().st_ino);
13+
i = uint64(int64(py.os.stat(p).st_ino)); % int64 first is for Matlab <= R2022a
1414
elseif isunix() && stdlib.java_api() >= 11
1515
% Java 1.8 is buggy in some corner cases, so we require at least 11.
1616
opt = javaMethod("values", "java.nio.file.LinkOption");
17-
i = javaMethod("getAttribute", "java.nio.file.Files", javaPathObject(path), "unix:ino", opt);
17+
i = javaMethod("getAttribute", "java.nio.file.Files", javaPathObject(p), "unix:ino", opt);
1818
elseif stdlib.isoctave()
19-
[s, err] = stat(path);
19+
[s, err] = stat(p);
2020
if err == 0
2121
i = s.ino;
2222
end

+stdlib/remove.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
% open files on Windows. This function mitigates that limitation by returning
66
% a boolean success status.
77

8-
function ok = remove(apath)
8+
function ok = remove(p)
99
arguments
10-
apath {mustBeTextScalar}
10+
p {mustBeTextScalar}
1111
end
1212

1313
ok = false;
1414

15-
if stdlib.isoctave() && ~stdlib.exists(apath)
15+
if stdlib.isoctave() && ~stdlib.exists(p)
1616
return
1717
end
1818

1919
%% fallback for if MEX not compiled
2020
try %#ok<*TRYNC>
21-
delete(apath);
21+
delete(p);
2222
ok = true;
2323
end
2424

0 commit comments

Comments
 (0)