Main Content

Link (H5L)

Links in HDF5 file

Description

Use the MATLAB® HDF5 link interface, H5L, to create and manipulate links in an HDF5 group. This interface includes functions that enable the creation and use of user-defined link classes.

Functions

H5L.copy

Copy link from source location to destination location

H5L.copy(srcID,srcname,destID,destname,lcplID,laplID) copies the link specified by srcname from the file or group specified by srcID to the destination destID. The new copy of the link is created with the name destname.

 Details

H5L.create_external

Create soft link to external object

H5L.create_external(filename,objname,linkID,linkname,lcplID,laplID) creates a soft link to an object in a different file.

 Details

H5L.create_hard

Create hard link

H5L.create_hard(objID,objname,linkID,linkname,lcplID,laplID) creates a new hard link to a preexisting object in an HDF5 file. The new link may be one of many that point to that object.

 Details

H5L.create_soft

Create soft link

H5L.create_soft(targetPath,linkID,linkname,lcplID,laplID) creates a new soft link to an object in an HDF5 file. The new link may be one of many that point to that object i.e., the object that the new soft link points to.

 Details

H5L.delete

Remove link

H5L.delete(locID,name,laplID) removes the link specified by name from the location locID based on the link access property list identifier specified by laplID.

H5L.exists

Determine if link exists

tf = H5L.exists(locID,linkname,laplID) checks if a link specified by the pairing of an object identifier and name exists within a group, based on the link access property list identifier specified by laplID.

H5L.get_info

Information about link

linkStruct = H5L.get_info(locID,linkname,laplID) returns information about a link. A file or group identifier, locID, specifies the location of the link. The linkname argument, interpreted relative to linkID, specifies the link being queried.

H5L.get_name_by_idx

Information about link specified by index

name = H5L.get_name_by_idx(locID,groupname,idxtype,order,n,laplID) retrieves information about a link at index n present in group groupname at location groupID.

name = H5L.get_name_by_idx(locID,groupname,idxtype,order,n,laplID,'TextEncoding',encoding) additionally specifies the text encoding to use to interpret the link name.

 Details

H5L.get_val

Value of symbolic link

linkval = H5L.get_val(linklocID,linkname,laplID) returns the value of a symbolic link. This function corresponds to the H5L.get_val and H5Lunpack_elink_val functions in the HDF5 1.8 C API.

linkval = H5L.get_val(linklocID,linkname,laplID,'TextEncoding',encoding) additionally specifies the text encoding to use to interpret the link value.

 Details

H5L.iterate

Iterate over links

[status,idxOut,opdataOut] = H5L.iterate(groupID,idxtype,order,idxIn,fnc,opdataIn) iterates through the links in a group, specified by groupID, to perform a common function whose function handle is fnc. H5L.iterate does not recursively follow links into subgroups of the specified group.

 Details

H5L.iterate_by_name

Iterate through links in group specified by name

[status,idx_out,opdataOut] = H5L.iterate_by_name(locID,groupname,idxtype,order,idxIn,fnc,opdataIn,laplID) iterates through the links in a group to perform a common function whose function handle is fnc. The starting point of the iteration is pairing of a specified by the location identifier and a relative group name. H5L.iterate_by_name does not recursively follow links into subgroups of the specified group. A link access property list, laplID, may affect the outcome depending upon the type of link being traversed.

 Details

H5L.move

Rename link

H5L.move(srcID,srcname,destID,destname,lcplID,laplID) renames a link within an HDF5 file. The original link, srcname, is removed from the group graph and the new link, destname, is inserted. This change is accomplished as an atomic operation.

 Details

H5L.visit

Recursively iterate through links in group specified by group identifier

[status,opdataOut] = H5L.visit(groupID,idxtype,order,fnc,opdataIn) recursively iterates through all links in and below a group, specified by groupID, to perform a common function whose function handle is fnc.

 Details

H5L.visit_by_name

Recursively iterate through links in group specified by location and group name

[status,opdataOut] = H5L.visit_by_name(locID,groupname,idxtype,order,fnc,opdataIn,laplID) recursively iterates though all links in and below a group to perform a common function whose function handle is fnc. The starting point of the iteration is specified by the pairing of a location id and a relative group name. A link access property list, laplID, may affect the outcome depending upon the type of link being traversed.

 Details

Examples

expand all

Remove the only link to the '/g3' group in example.h5.

srcFile = fullfile(matlabroot,'toolbox','matlab','demos','example.h5');
copyfile(srcFile,'myfile.h5');
fileattrib('myfile.h5','+w');
fid = H5F.open('myfile.h5','H5F_ACC_RDWR','H5P_DEFAULT');
H5L.delete(fid,'g3','H5P_DEFAULT');
H5F.close(fid);
fid = H5F.open('example.h5');
gid = H5G.open(fid,'/g1/g1.2/g1.2.1');
if H5L.exists(gid,'slink','H5P_DEFAULT')
    fprintf('link exists\n');
else
    fprintf('link does not exist\n');
end

Rename the '/g2' group to '/g2/g3'.

srcFile = fullfile(matlabroot,'toolbox','matlab','demos','example.h5');
copyfile(srcFile,'myfile.h5');
fileattrib('myfile.h5','+w');
fid = H5F.open('myfile.h5','H5F_ACC_RDWR','H5P_DEFAULT');
g2id = H5G.open(fid,'g2');
H5L.move(fid,'g3',g2id,'g3','H5P_DEFAULT','H5P_DEFAULT');
H5G.close(g2id);
H5F.close(fid);
Introduced before R2006a