summaryrefslogtreecommitdiffstats
path: root/test/links.c
blob: ac4a3e1e1decd9caa354d7ca9e81cd2247f46de9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Copyright (C) 1998 NCSA
 *                    All rights reserved.
 *
 * Programmer:  Robb Matzke <matzke@llnl.gov>
 *              Friday, April 10, 1998
 *
 * Purpose:	Tests hard and soft (symbolic) links.
 */
#include <hdf5.h>


/*-------------------------------------------------------------------------
 * Function:	main
 *
 * Purpose:	Tests links.
 *
 * Return:	Success:	0
 *
 *		Failure:	non-zero
 *
 * Programmer:	Robb Matzke
 *              Friday, April 10, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
int
main (void)
{
    hid_t	file, scalar, grp, d1;
    hsize_t	size[1] = {1};

    /* Create a file */
    file = H5Fcreate ("links.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    scalar = H5Screate_simple (1, size, size);

    /* Create a group */
    grp = H5Gcreate (file, "grp1", 0);
    H5Gclose (grp);

    /* Create a dataset */
    d1 = H5Dcreate (file, "d1", H5T_NATIVE_INT, scalar, H5P_DEFAULT);
    H5Dclose (d1);

    /* Create a hard link */
    H5Glink (file, H5G_LINK_HARD, "d1", "grp1/hard");

    /* Create a symbolic link */
    H5Glink (file, H5G_LINK_SOFT, "/d1", "grp1/soft");

    /* Create a symbolic link to something that doesn't exist */
    H5Glink (file, H5G_LINK_SOFT, "foobar", "grp1/dangle");

    /* Create a recursive symbolic link */
    H5Glink (file, H5G_LINK_SOFT, "/grp1/recursive", "/grp1/recursive");

    /* Close */
    H5Sclose (scalar);
    H5Fclose (file);
    return 0;
}