Skip to content

Commit bb7cf01

Browse files
committed
work >= R2020a. Remove copyfile. ncvariables(..., group) option
1 parent c82d35e commit bb7cf01

35 files changed

+214
-188
lines changed

+stdlib/+fileio/absolute_path.m

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010
p (1,:) string
1111
end
1212

13-
import stdlib.fileio.expanduser
14-
import stdlib.fileio.is_absolute_path
15-
1613
% have to expand ~ first
17-
p = expanduser(p);
14+
p = stdlib.fileio.expanduser(p);
1815

19-
if ~is_absolute_path(p)
16+
if ~stdlib.fileio.is_absolute_path(p)
2017
% otherwise the default is Documents/Matlab, which is probably not wanted.
2118
p = fullfile(pwd, p);
2219
end

+stdlib/+fileio/copyfile.m

Lines changed: 0 additions & 22 deletions
This file was deleted.

+stdlib/+fileio/extract_zstd.m

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,21 @@ function extract_zstd(archive, out_dir)
55
% For our user audience, CMake is at least as likely to be installed as Zstd.
66

77
arguments
8-
archive (1,1) string
8+
archive (1,1) string {mustBeFile}
99
out_dir (1,1) string
1010
end
1111

12-
import stdlib.fileio.absolute_path
13-
import stdlib.fileio.which
14-
import stdlib.sys.subprocess_run
15-
16-
archive = absolute_path(archive);
17-
out_dir = absolute_path(out_dir);
12+
archive = stdlib.fileio.absolute_path(archive);
13+
out_dir = stdlib.fileio.absolute_path(out_dir);
1814

19-
assert(isfile(archive), "%s is not a file", archive)
2015
assert(isfolder(out_dir), "%s is not a folder", out_dir)
2116

22-
exe = which("cmake");
17+
exe = stdlib.fileio.which("cmake");
2318
if isempty(exe)
2419
extract_zstd_bin(archive, outdir)
2520
end
2621

27-
[ret, msg] = subprocess_run([exe, "-E", "tar", "xf", archive], "cwd", out_dir);
22+
[ret, msg] = stdlib.sys.subprocess_run([exe, "-E", "tar", "xf", archive], "cwd", out_dir);
2823
assert(ret == 0, "problem extracting %s %s", archive, msg)
2924

3025
end

+stdlib/+fileio/is_exe.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
% is a file executable?
44

55
arguments
6-
file (1,1) string
6+
file (1,1) string {mustBeNonzeroLengthText}
77
end
88

99
if ~isfile(file)

+stdlib/+fileio/md5sum.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
function hash = md5sum(file)
22
% compute MD5 hash of file
33
arguments
4-
file (1,1) string {mustBeNonzeroLengthText}
4+
file (1,1) string {mustBeFile}
55
end
66

7-
import stdlib.fileio.expanduser
8-
9-
file = expanduser(file);
7+
file = stdlib.fileio.expanduser(file);
108

119
if ismac
1210
[stat,hash] = system("md5 -r " + file);

+stdlib/+fileio/private/mustBeFile.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function mustBeFile(a)
2+
arguments
3+
a string {mustBeNonzeroLengthText}
4+
end
5+
6+
assert(all(isfile(stdlib.fileio.expanduser(a)), 'all'), "%s is not a file", a)
7+
8+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function mustBeNonzeroLengthText(a)
2+
3+
if ~((ischar(a) || isstring(a) || iscellstr(a)) && all(strlength(a) > 0, 'all'))
4+
error("MATLAB:validators:mustBeNonzeroLengthText", "text must have non-zero length")
5+
end
6+
7+
end

+stdlib/+fileio/sha256sum.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
function hash = sha256sum(file)
22
% compute sha256 hash of file
33
arguments
4-
file (1,1) string {mustBeNonzeroLengthText}
4+
file (1,1) string {mustBeFile}
55
end
66

7-
import stdlib.fileio.expanduser
8-
9-
file = expanduser(file);
7+
file = stdlib.fileio.expanduser(file);
108

119
if ismac
1210
[stat,hash] = system("shasum --algorithm 256 --binary " + file);

+stdlib/+hdf5nc/h5create_group.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@
1717
else
1818
file = expanduser(file);
1919
dcpl = 'H5P_DEFAULT';
20-
try
20+
if isfile(file)
2121
fid = H5F.open(file, 'H5F_ACC_RDWR', dcpl);
22-
catch e
23-
if e.identifier == "MATLAB:imagesci:hdf5io:resourceNotFound"
24-
fid = H5F.create(file);
25-
else
26-
rethrow(e)
27-
end
22+
else
23+
fid = H5F.create(file);
2824
end
2925
end
3026

+stdlib/+hdf5nc/h5exists.m

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
function exists = h5exists(file, varnames)
1+
function exists = h5exists(file, vars)
22
% check if object(s) exists in HDF5 file
33
%
44
% parameters
55
% ----------
66
% file: HDF5 filename
7-
% varname: name of variable in file
7+
% varname: path(s) of variable in file
88
%
99
% returns
1010
% -------
1111
% exists: boolean (scalar or vector)
1212

1313
arguments
14-
file (1,1) string {mustBeNonzeroLengthText}
15-
varnames (1,:) string {mustBeNonempty,mustBeNonzeroLengthText}
14+
file (1,1) string {mustBeFile}
15+
vars (1,:) string {mustBeNonempty,mustBeNonzeroLengthText}
1616
end
1717

18-
import stdlib.hdf5nc.h5variables
19-
20-
i = startsWith(varnames, "/");
21-
varnames(i) = extractAfter(varnames(i), 1);
18+
i = startsWith(vars, "/");
19+
vars(i) = extractAfter(vars(i), 1);
2220
% NOT contains because we want exact string match
23-
exists = ismember(varnames, h5variables(file));
21+
exists = ismember(vars, stdlib.hdf5nc.h5variables(file));
2422

2523
end % function

0 commit comments

Comments
 (0)