HARD_LINK_COUNT get the number of hard links to a file

Contents

inputs

Outputs

Java backend references:

function [i, b] = hard_link_count(file, backend)
if nargin < 2
  backend = {'java', 'python', 'sys'};
else
  backend = cellstr(backend);
end

i = [];

for j = 1:numel(backend)
  b = backend{j};
  switch b
    case "java"
      i = stdlib.java.hard_link_count(file);
    case "python"
      if stdlib.matlabOlderThan('R2022a'), continue, end
      i = stdlib.python.hard_link_count(file);
    case "sys"
      i = stdlib.sys.hard_link_count(file);
    otherwise
      error("stdlib:hard_link_count:ValueError", "Unknown backend: %s", b)
  end

  if ~isempty(i)
    return
  end
end

end


%!assert (stdlib.hard_link_count('.') > 0)