Permalink
Browse files
ENH: support for "hash" function in more recent version of Octave
- Loading branch information...
Showing
with
24 additions
and
15 deletions.
-
+3
−3
MOcov/mocov_find_files.m
-
+20
−11
MOcov/mocov_util_md5.m
-
+1
−1
README.md
|
|
@@ -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);
|
|
|
|
|
|
|
|
|
@@ -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;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@@ -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
|
|
|
|
0 comments on commit
9834cdb