Skip to content

Commit 519c422

Browse files
committed
filesystem_type, get_owner: require path to exist
1 parent b4e6f42 commit 519c422

File tree

8 files changed

+13
-16
lines changed

8 files changed

+13
-16
lines changed

+stdlib/checkRAM.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
function [OK,newSizeBytes,freebytes] = checkRAM(newSize, myclass)
99
arguments
1010
newSize (1,:) {mustBeNumeric}
11-
myclass (1,1) string
11+
myclass {mustBeTextScalar}
1212
end
1313

1414
% get available RAM

+stdlib/create_symlink.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
function ok = create_symlink(target, link)
1111
arguments
12-
target (1,1) string
13-
link (1,1) string
12+
target {mustBeTextScalar}
13+
link {mustBeTextScalar}
1414
end
1515

1616

+stdlib/disk_available.m

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

88
function f = disk_available(d)
99
arguments
10-
d (1,1) string
10+
d {mustBeTextScalar}
1111
end
1212

1313
f = javaFileObject(d).getUsableSpace();

+stdlib/disk_capacity.m

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

66
function f = disk_capacity(d)
77
arguments
8-
d (1,1) string
8+
d {mustBeTextScalar}
99
end
1010

1111
f = javaFileObject(d).getTotalSpace();

+stdlib/exists.m

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

1212
function y = exists(p)
1313
arguments
14-
p (1,1) string
14+
p {mustBeTextScalar}
1515
end
1616

1717
% Matlab >= R2024b allowed URLs to act like files or folders.

+stdlib/filesystem_type.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@
88

99
function t = filesystem_type(p)
1010
arguments
11-
p (1,1) string = ""
11+
p {mustBeTextScalar} = ''
1212
end
1313

14-
t = "";
15-
16-
if strlength(p) && ~stdlib.exists(p), return, end
14+
assert(stdlib.exists(p), "Path does not exist: %s", p);
1715

1816
op = javaPathObject(p);
1917

2018
if stdlib.isoctave()
2119
t = javaMethod("getFileStore", "java.nio.file.Files", op).type;
2220
else
23-
t = string(java.nio.file.Files.getFileStore(op).type);
21+
t = java.nio.file.Files.getFileStore(op).type.string;
2422
end
2523

2624
end

+stdlib/get_owner.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@
77
% * n: owner, or empty if path does not exist
88
function n = get_owner(p)
99
arguments
10-
p (1,1) string
10+
p {mustBeTextScalar}
1111
end
1212

1313
% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/Files.html#getOwner(java.nio.file.Path,java.nio.file.LinkOption...)
1414
% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/LinkOption.html
1515

16-
n = "";
17-
if ~stdlib.exists(p), return, end
16+
assert(stdlib.exists(p), "Path %s does not exist.", p)
1817

1918
op = javaPathObject(p);
2019
opt = javaLinkOption();
2120

2221
if stdlib.isoctave()
2322
n = javaMethod("getOwner", "java.nio.file.Files", op, opt).toString();
2423
else
25-
n = string(java.nio.file.Files.getOwner(op, opt));
24+
n = java.nio.file.Files.getOwner(op, opt).string;
2625
end
2726

2827
end

test/TestJava.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
classdef TestJava < matlab.unittest.TestCase
22

33
properties (TestParameter)
4-
Ps = {".", "", "not-exist"}
4+
Ps = {"."}
55
end
66

77
methods(TestClassSetup)

0 commit comments

Comments
 (0)