Skip to content

Commit 49b2c87

Browse files
committed
remove use_java option for clarity/brevity
1 parent 684b904 commit 49b2c87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+327
-405
lines changed

+stdlib/absolute.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
% does not normalize path
1717
% non-existant path is made absolute relative to pwd
1818

19-
function c = absolute(p, base, expand_tilde, use_java)
19+
function c = absolute(p, base, expand_tilde)
2020
arguments
2121
p (1,1) string
2222
base (1,1) string = ""
2323
expand_tilde (1,1) logical = true
24-
use_java (1,1) logical = false
2524
end
2625

2726
if expand_tilde
28-
c = stdlib.expanduser(p, use_java);
27+
c = stdlib.expanduser(p);
2928
else
3029
c = stdlib.posix(p);
3130
end
@@ -37,7 +36,7 @@
3736
if stdlib.len(base) == 0
3837
b = pwd();
3938
elseif expand_tilde
40-
b = stdlib.expanduser(base, use_java);
39+
b = stdlib.expanduser(base);
4140
else
4241
b = base;
4342
end

+stdlib/canonical.m

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@
1111
% * expand_tilde: expand ~ to username if present
1212
%%% Outputs
1313
% * c: canonical path, if determined
14-
% https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/File.html#getCanonicalPath()
1514

16-
function c = canonical(p, expand_tilde, use_java)
15+
function c = canonical(p, expand_tilde)
1716
arguments
1817
p (1,1) string
1918
expand_tilde (1,1) logical = true
20-
use_java (1,1) logical = false
2119
end
2220

2321

2422
if expand_tilde
25-
e = stdlib.expanduser(p, use_java);
23+
e = stdlib.expanduser(p);
2624
else
2725
e = p;
2826
end
@@ -39,10 +37,6 @@
3937
if stdlib.isoctave()
4038
% empty if any component of path does not exist
4139
c = canonicalize_file_name(e);
42-
elseif use_java && stdlib.is_absolute(e, true)
43-
% incorrect result if relative path and any component of path does not exist
44-
% disp("java")
45-
c = javaFileObject(e).getCanonicalPath();
4640
else
4741
% errors if any component of path does not exist.
4842
% disp("builtin")
@@ -52,7 +46,7 @@
5246
end
5347

5448
if ~stdlib.len(c)
55-
c = stdlib.normalize(e, use_java);
49+
c = stdlib.normalize(e);
5650
end
5751

5852
c = stdlib.posix(c);

+stdlib/cpu_count.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
%% CPU_COUNT how many CPUs are available
22
function N = cpu_count()
33

4-
N = maxNumCompThreads;
4+
N = maxNumCompThreads;
55

6-
if N < 2 && ~stdlib.isoctave() % happens on some HPC
7-
N = feature('NumCores');
8-
end
6+
if N < 2 && ~stdlib.isoctave() % happens on some HPC
7+
N = feature('NumCores');
8+
end
99

1010
% logical CPUs
1111
% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/Runtime.html#getRuntime()

+stdlib/drop_slash.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
return;
2424
end
2525

26-
if ~ispc || (L ~= 3 || ~strcmp(d, stdlib.root(s, false)))
26+
if ~ispc || (L ~= 3 || ~strcmp(d, stdlib.root(s)))
2727
if ischar(s)
2828
if d(end) == '/'
2929
d = d(1:end-1);

+stdlib/exists.m

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,13 @@
88
% * p: path to check
99
%%% Outputs
1010
% * ok: true if exists
11-
%
1211

13-
function ok = exists(p, use_java)
12+
function ok = exists(p)
1413
arguments
1514
p (1,1) string
16-
use_java (1,1) logical = false
1715
end
1816

19-
if use_java
20-
% Windows: does NOT detect App Execution Aliases
21-
% https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#exists(java.nio.file.Path,java.nio.file.LinkOption...)
22-
% this takes 2x longer than java.io.File.exists()
23-
% opt = javaLinkOption();
24-
% ok = java.nio.file.Files.exists(java.io.File(p).toPath(), opt);
25-
26-
% https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/File.html#exists()
27-
% takes 2x longer than native Matlab isfile || isfolder
28-
ok = javaFileObject(p).exists();
29-
else
30-
ok = isfile(p) || isfolder(p);
31-
end
17+
ok = isfile(p) || isfolder(p);
3218

3319
end
3420

+stdlib/expanduser.m

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
%%% Outputs
88
% * e: expanded path
99

10-
function e = expanduser(p, use_java)
10+
function e = expanduser(p)
1111
arguments
1212
p (1,1) string
13-
use_java (1,1) logical = false
1413
end
1514

1615
e = stdlib.drop_slash(p);
@@ -20,7 +19,7 @@
2019
return
2120
end
2221

23-
home = stdlib.homedir(use_java);
22+
home = stdlib.homedir();
2423

2524
if stdlib.len(home) == 0
2625
return
@@ -41,9 +40,9 @@
4140
end
4241

4342

44-
%!assert(expanduser('', 0), '')
45-
%!assert(expanduser("~", 0), homedir())
46-
%!assert(expanduser("~/", 0), homedir())
47-
%!assert(expanduser("~user", 0), "~user")
48-
%!assert(expanduser("~user/", 0), "~user")
49-
%!assert(expanduser("~///c", 0), strcat(homedir(), "/c"))
43+
%!assert(expanduser(''), '')
44+
%!assert(expanduser("~"), homedir())
45+
%!assert(expanduser("~/"), homedir())
46+
%!assert(expanduser("~user"), "~user")
47+
%!assert(expanduser("~user/"), "~user")
48+
%!assert(expanduser("~///c"), strcat(homedir(), "/c"))

+stdlib/file_size.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
% FILE_SIZE size in bytes of file
22

3-
function s = file_size(p, use_java)
3+
function s = file_size(p)
44
arguments
55
p (1,1) string
6-
use_java (1,1) logical = false
76
end
87

98
s = [];
109

1110
if ~isfile(p)
1211
return
13-
elseif use_java
14-
s = javaFileObject(p).length();
1512
else
1613
s = dir(p);
1714
if ~isempty(s)

+stdlib/get_modtime.m

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,10 @@
77

88
if stdlib.exists(p)
99

10-
utc = javaFileObject(p).lastModified() / 1000;
10+
t = javaFileObject(p).lastModified() / 1000;
1111

12-
try
13-
t = datetime(utc, "ConvertFrom", "PosixTime");
14-
catch e
15-
if strcmp(e.identifier, "Octave:undefined-function")
16-
t = utc;
17-
else
18-
rethrow(e);
19-
end
12+
try %#ok<TRYNC>
13+
t = datetime(t, "ConvertFrom", "PosixTime");
2014
end
2115
else
2216
try

+stdlib/h5get_version.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
v = sprintf("%d.%d.%d", major, minor, rel);
88

99
end
10+
11+
%!testif 0

+stdlib/homedir.m

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
%% HOMEDIR get user home directory
2-
%
3-
% Ref:
4-
% * https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/System.html#getProperty(java.lang.String)
5-
% * https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/System.html#getProperties()
62

7-
function h = homedir(use_java)
8-
arguments
9-
use_java (1,1) logical = false
10-
end
3+
function h = homedir()
114

12-
if use_java
13-
h = javaSystemProperty("user.home");
14-
elseif ispc
5+
if ispc
156
h = getenv("USERPROFILE");
167
else
178
h = getenv("HOME");

0 commit comments

Comments
 (0)