diff --git a/MOcov/mocov_find_files.m b/MOcov/mocov_find_files.m index ffb8850..ee5f8ba 100644 --- a/MOcov/mocov_find_files.m +++ b/MOcov/mocov_find_files.m @@ -55,8 +55,8 @@ end res=find_files_recursively(root_dir,file_re,monitor,exclude_re); - - + + function re=pattern2re(pat) re=['^' ... % start of the string regexptranslate('wildcard',pat) ... @@ -71,7 +71,7 @@ excl_re_cell=cellfun(@pattern2re,exclude_pat,... 'UniformOutput',false); - + joined=sprintf('|%s',excl_re_cell{:}); re=joined(2:end); diff --git a/MOcov/mocov_util_md5.m b/MOcov/mocov_util_md5.m index a563ac8..bb96d93 100644 --- a/MOcov/mocov_util_md5.m +++ b/MOcov/mocov_util_md5.m @@ -20,7 +20,9 @@ function md5=md5_from_file(fn) - md5_processors={@md5_builtin,@md5_shell}; + md5_processors={@md5_builtin,... + @hash_builtin,... + @md5_shell}; n=numel(md5_processors); for k=1:n @@ -34,14 +36,29 @@ error('Unable to compute md5 - no method available'); function [is_ok,md5]=md5_builtin(fn) -% supported in GNU Octave - is_ok=~isempty(which('md5sum')); +% supported in GNU Octave <= 4.6 + is_ok=has_builtin_function('md5sum'); if is_ok md5=md5sum(fn); else md5=[]; end + +function [is_ok,md5]=hash_builtin(fn) +% supported in GNU Octave >= 4.4 + + is_ok=has_builtin_function('hash') && has_builtin_function('fileread'); + if is_ok + md5=hash('md5',fileread(fn)); + else + md5=[]; + end + +function tf=has_builtin_function(name) + tf=exist(name,'builtin'); + + function [is_ok,md5]=md5_shell(fn) % supported on Unix platform is_ok=false; @@ -55,11 +72,3 @@ [status,md5]=unix(cmd); is_ok=status==0; - - - - - - - - diff --git a/README.md b/README.md index 24fabba..1cc14b8 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ Nikolaas N. Oosterhof, nikolaas dot oosterhof at unitn dot it (The MIT License) -Copyright (c) 2015 Nikolaas N. Oosterhof +Copyright (c) 2015-2017 Nikolaas N. Oosterhof Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the