PARENT parent directory of path

Contents

inputs

Outputs

Examples:

stdlib.parent('a/b/c') 'a/b' stdlib.parent('a/b/c/') 'a/b'

function p = parent(file)

p = fileparts(stdlib.drop_slash(file));

if stdlib.strempty(p)
  p = '.';
  if isstring(file)
    p = string(p);
  end
elseif ispc() && strcmp(p, stdlib.root_name(file))
  p = stdlib.append(p, '/');
end

end

%!assert (stdlib.parent('a/b/'), 'a')