diff --git a/+stdlib/+fileio/md5sum.m b/+stdlib/+fileio/md5sum.m index 3c4d2f9..edd0c2d 100644 --- a/+stdlib/+fileio/md5sum.m +++ b/+stdlib/+fileio/md5sum.m @@ -5,19 +5,17 @@ file (1,1) string {mustBeFile} end -file = stdlib.fileio.expanduser(file); - if ismac - [stat,hash] = system("md5 -r " + file); + [stat, hash] = system("md5 -r " + file); elseif isunix - [stat,hash] = system("md5sum " + file); + [stat, hash] = system("md5sum " + file); elseif ispc - [stat,hash] = system("CertUtil -hashfile " + file + " MD5"); + [stat, hash] = system("CertUtil -hashfile " + file + " MD5"); else error("no sha256sum method for your OS") end -assert(stat == 0, hash) +assert(stat == 0, hash, "failed to compute md5sum of " + file) hash = regexp(hash,'^\w{32}','match','once','lineanchors'); hash = string(hash); diff --git a/+stdlib/+fileio/sha256sum.m b/+stdlib/+fileio/sha256sum.m index 46be8e8..40db1e8 100644 --- a/+stdlib/+fileio/sha256sum.m +++ b/+stdlib/+fileio/sha256sum.m @@ -4,19 +4,17 @@ file (1,1) string {mustBeFile} end -file = stdlib.fileio.expanduser(file); - if ismac - [stat,hash] = system("shasum --algorithm 256 --binary " + file); + [stat, hash] = system("shasum --algorithm 256 --binary " + file); elseif isunix - [stat,hash] = system("sha256sum --binary " + file); + [stat, hash] = system("sha256sum --binary " + file); elseif ispc - [stat,hash] = system("CertUtil -hashfile " + file + " SHA256"); + [stat, hash] = system("CertUtil -hashfile " + file + " SHA256"); else - error("no md5sum method for your OS") + error("no sha256sum method for your OS") end -assert(stat == 0, hash) +assert(stat == 0, hash, "failed to compute SHA256 hash of " + file) hash = regexp(hash,'^\w{64}','match','once','lineanchors'); hash = string(hash); diff --git a/+stdlib/+hdf5nc/h5ndims.m b/+stdlib/+hdf5nc/h5ndims.m index 3cda9b4..6de2ff1 100644 --- a/+stdlib/+hdf5nc/h5ndims.m +++ b/+stdlib/+hdf5nc/h5ndims.m @@ -10,7 +10,7 @@ return end -dsi = h5info(stdlib.fileio.expanduser(file), variable).Dataspace; +dsi = h5info(file, variable).Dataspace; if dsi.Type == "scalar" frank = 0; else diff --git a/+stdlib/+hdf5nc/h5size.m b/+stdlib/+hdf5nc/h5size.m index 058a0fb..5013963 100644 --- a/+stdlib/+hdf5nc/h5size.m +++ b/+stdlib/+hdf5nc/h5size.m @@ -5,7 +5,7 @@ variable (1,1) string {mustBeNonzeroLengthText} end -dsi = h5info(stdlib.fileio.expanduser(file), variable).Dataspace; +dsi = h5info(file, variable).Dataspace; if dsi.Type == "scalar" fsize = []; else diff --git a/+stdlib/+hdf5nc/h5variables.m b/+stdlib/+hdf5nc/h5variables.m index e8e10f9..5880b80 100644 --- a/+stdlib/+hdf5nc/h5variables.m +++ b/+stdlib/+hdf5nc/h5variables.m @@ -8,9 +8,9 @@ names = string.empty; if isempty(group) || strlength(group) == 0 - finf = h5info(stdlib.fileio.expanduser(file)); + finf = h5info(file); else - finf = h5info(stdlib.fileio.expanduser(file), group); + finf = h5info(file, group); end ds = finf.Datasets; diff --git a/+stdlib/+hdf5nc/ncndims.m b/+stdlib/+hdf5nc/ncndims.m index 3e048c2..1862711 100644 --- a/+stdlib/+hdf5nc/ncndims.m +++ b/+stdlib/+hdf5nc/ncndims.m @@ -10,7 +10,7 @@ return end -dsi = ncinfo(stdlib.fileio.expanduser(file), variable); +dsi = ncinfo(file, variable); if isempty(dsi.Dimensions) frank = 0; else diff --git a/+stdlib/+hdf5nc/ncsize.m b/+stdlib/+hdf5nc/ncsize.m index bac86e8..4b1c5bb 100644 --- a/+stdlib/+hdf5nc/ncsize.m +++ b/+stdlib/+hdf5nc/ncsize.m @@ -5,7 +5,7 @@ variable (1,1) string {mustBeNonzeroLengthText} end -dsi = ncinfo(stdlib.fileio.expanduser(file), variable); +dsi = ncinfo(file, variable); if isempty(dsi.Dimensions) fsize = []; else diff --git a/+stdlib/+hdf5nc/ncvariables.m b/+stdlib/+hdf5nc/ncvariables.m index 50ab67c..6f5b56e 100644 --- a/+stdlib/+hdf5nc/ncvariables.m +++ b/+stdlib/+hdf5nc/ncvariables.m @@ -8,9 +8,9 @@ names = string.empty; if isempty(group) || strlength(group) == 0 - finf = ncinfo(stdlib.fileio.expanduser(file)); + finf = ncinfo(file); else - finf = ncinfo(stdlib.fileio.expanduser(file), group); + finf = ncinfo(file, group); end ds = finf.Variables(:); diff --git a/+stdlib/+sys/diskfree.m b/+stdlib/+sys/diskfree.m index 0468a73..fc24d67 100644 --- a/+stdlib/+sys/diskfree.m +++ b/+stdlib/+sys/diskfree.m @@ -1,15 +1,11 @@ function freebytes = diskfree(direc) %% diskfree(direc) % returns disk free space in bytes -% example: diskfree('~') +% example: diskfree('/') arguments - direc (1,1) string + direc (1,1) string {mustBeFolder} end -direc = stdlib.fileio.expanduser(direc); - -assert(isfolder(direc), '%s is not a folder', direc) - freebytes = java.io.File(direc).getUsableSpace; end diff --git a/+stdlib/+test/TestIntg.m b/+stdlib/+test/TestIntg.m index 4f10e08..adc5d45 100644 --- a/+stdlib/+test/TestIntg.m +++ b/+stdlib/+test/TestIntg.m @@ -11,8 +11,8 @@ function test_checkRAM(tc) function test_diskfree(tc) tc.assumeTrue(usejava("jvm"), "Java required for path_tail") -tc.assertTrue(isnumeric(stdlib.sys.diskfree('~'))) -tc.assertTrue(stdlib.sys.diskfree('~') > 0, 'diskfree') +tc.assertTrue(isnumeric(stdlib.sys.diskfree('/'))) +tc.assertTrue(stdlib.sys.diskfree('/') > 0, 'diskfree') end function test_memory(tc) diff --git a/Readme.md b/Readme.md index 6cf951d..dcc6447 100644 --- a/Readme.md +++ b/Readme.md @@ -1,4 +1,4 @@ -# Matlab standard library +# Standard library for Matlab [![DOI](https://zenodo.org/badge/273830124.svg)](https://zenodo.org/badge/latestdoi/273830124) [![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)