Skip to content

Commit 9b8a868

Browse files
committed
remove redundant code
1 parent 993a54f commit 9b8a868

File tree

11 files changed

+22
-30
lines changed

11 files changed

+22
-30
lines changed

+stdlib/+fileio/md5sum.m

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@
55
file (1,1) string {mustBeFile}
66
end
77

8-
file = stdlib.fileio.expanduser(file);
9-
108
if ismac
11-
[stat,hash] = system("md5 -r " + file);
9+
[stat, hash] = system("md5 -r " + file);
1210
elseif isunix
13-
[stat,hash] = system("md5sum " + file);
11+
[stat, hash] = system("md5sum " + file);
1412
elseif ispc
15-
[stat,hash] = system("CertUtil -hashfile " + file + " MD5");
13+
[stat, hash] = system("CertUtil -hashfile " + file + " MD5");
1614
else
1715
error("no sha256sum method for your OS")
1816
end
1917

20-
assert(stat == 0, hash)
18+
assert(stat == 0, hash, "failed to compute md5sum of " + file)
2119

2220
hash = regexp(hash,'^\w{32}','match','once','lineanchors');
2321
hash = string(hash);

+stdlib/+fileio/sha256sum.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@
44
file (1,1) string {mustBeFile}
55
end
66

7-
file = stdlib.fileio.expanduser(file);
8-
97
if ismac
10-
[stat,hash] = system("shasum --algorithm 256 --binary " + file);
8+
[stat, hash] = system("shasum --algorithm 256 --binary " + file);
119
elseif isunix
12-
[stat,hash] = system("sha256sum --binary " + file);
10+
[stat, hash] = system("sha256sum --binary " + file);
1311
elseif ispc
14-
[stat,hash] = system("CertUtil -hashfile " + file + " SHA256");
12+
[stat, hash] = system("CertUtil -hashfile " + file + " SHA256");
1513
else
16-
error("no md5sum method for your OS")
14+
error("no sha256sum method for your OS")
1715
end
1816

19-
assert(stat == 0, hash)
17+
assert(stat == 0, hash, "failed to compute SHA256 hash of " + file)
2018

2119
hash = regexp(hash,'^\w{64}','match','once','lineanchors');
2220
hash = string(hash);

+stdlib/+hdf5nc/h5ndims.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
return
1111
end
1212

13-
dsi = h5info(stdlib.fileio.expanduser(file), variable).Dataspace;
13+
dsi = h5info(file, variable).Dataspace;
1414
if dsi.Type == "scalar"
1515
frank = 0;
1616
else

+stdlib/+hdf5nc/h5size.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
variable (1,1) string {mustBeNonzeroLengthText}
66
end
77

8-
dsi = h5info(stdlib.fileio.expanduser(file), variable).Dataspace;
8+
dsi = h5info(file, variable).Dataspace;
99
if dsi.Type == "scalar"
1010
fsize = [];
1111
else

+stdlib/+hdf5nc/h5variables.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
names = string.empty;
99

1010
if isempty(group) || strlength(group) == 0
11-
finf = h5info(stdlib.fileio.expanduser(file));
11+
finf = h5info(file);
1212
else
13-
finf = h5info(stdlib.fileio.expanduser(file), group);
13+
finf = h5info(file, group);
1414
end
1515

1616
ds = finf.Datasets;

+stdlib/+hdf5nc/ncndims.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
return
1111
end
1212

13-
dsi = ncinfo(stdlib.fileio.expanduser(file), variable);
13+
dsi = ncinfo(file, variable);
1414
if isempty(dsi.Dimensions)
1515
frank = 0;
1616
else

+stdlib/+hdf5nc/ncsize.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
variable (1,1) string {mustBeNonzeroLengthText}
66
end
77

8-
dsi = ncinfo(stdlib.fileio.expanduser(file), variable);
8+
dsi = ncinfo(file, variable);
99
if isempty(dsi.Dimensions)
1010
fsize = [];
1111
else

+stdlib/+hdf5nc/ncvariables.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
names = string.empty;
99

1010
if isempty(group) || strlength(group) == 0
11-
finf = ncinfo(stdlib.fileio.expanduser(file));
11+
finf = ncinfo(file);
1212
else
13-
finf = ncinfo(stdlib.fileio.expanduser(file), group);
13+
finf = ncinfo(file, group);
1414
end
1515

1616
ds = finf.Variables(:);

+stdlib/+sys/diskfree.m

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
function freebytes = diskfree(direc)
22
%% diskfree(direc)
33
% returns disk free space in bytes
4-
% example: diskfree('~')
4+
% example: diskfree('/')
55
arguments
6-
direc (1,1) string
6+
direc (1,1) string {mustBeFolder}
77
end
88

9-
direc = stdlib.fileio.expanduser(direc);
10-
11-
assert(isfolder(direc), '%s is not a folder', direc)
12-
139
freebytes = java.io.File(direc).getUsableSpace;
1410

1511
end

+stdlib/+test/TestIntg.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ function test_checkRAM(tc)
1111
function test_diskfree(tc)
1212
tc.assumeTrue(usejava("jvm"), "Java required for path_tail")
1313

14-
tc.assertTrue(isnumeric(stdlib.sys.diskfree('~')))
15-
tc.assertTrue(stdlib.sys.diskfree('~') > 0, 'diskfree')
14+
tc.assertTrue(isnumeric(stdlib.sys.diskfree('/')))
15+
tc.assertTrue(stdlib.sys.diskfree('/') > 0, 'diskfree')
1616
end
1717

1818
function test_memory(tc)

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Matlab standard library
1+
# Standard library for Matlab
22

33
[![DOI](https://zenodo.org/badge/273830124.svg)](https://zenodo.org/badge/latestdoi/273830124)
44
[![View matlab-hdf5 on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/78673-matlab-hdf5)

0 commit comments

Comments
 (0)