diff options
author | kmu <kmu@hdfgroup.org> | 2019-11-27 03:59:51 (GMT) |
---|---|---|
committer | kmu <kmu@hdfgroup.org> | 2019-11-27 03:59:51 (GMT) |
commit | ea0759d047dc6421da90375a9c27f7cde0a8e117 (patch) | |
tree | 81df83e8c53a80b61365d579b26aeb9532fe493f /test/H5srcdir.c | |
parent | e0262c8bedf0e59b7b32b02ecd91ed50cf834a1c (diff) | |
parent | 9f61c26927ac74c4498cbebd7c9f2166d5f5b786 (diff) | |
download | hdf5-ea0759d047dc6421da90375a9c27f7cde0a8e117.zip hdf5-ea0759d047dc6421da90375a9c27f7cde0a8e117.tar.gz hdf5-ea0759d047dc6421da90375a9c27f7cde0a8e117.tar.bz2 |
Merge branch 'develop' of https://git.hdfgroup.org/scm/hdffv/hdf5 into develop
Diffstat (limited to 'test/H5srcdir.c')
-rw-r--r-- | test/H5srcdir.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/H5srcdir.c b/test/H5srcdir.c new file mode 100644 index 0000000..8268d2c --- /dev/null +++ b/test/H5srcdir.c @@ -0,0 +1,61 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "H5private.h" +#include "H5srcdir.h" + +/* Buffer to construct path in and return pointer to */ +char srcdir_path[1024] = ""; + +/* Buffer to construct file in and return pointer to */ +char srcdir_testpath[1024] = ""; + +/* Just return the srcdir path */ +const char * +H5_get_srcdir(void) +{ + const char *srcdir = HDgetenv("srcdir"); + + /* Check for using the srcdir from configure time */ + if(NULL == srcdir) + srcdir = config_srcdir; + + /* Build path to all test files */ + if((HDstrlen(srcdir) + 2) < sizeof(srcdir_path)) { + HDsnprintf(srcdir_path, sizeof(srcdir_path), "%s/", srcdir); + return(srcdir_path); + } /* end if */ + else + return(NULL); +} /* end H5_get_srcdir() */ + +/* Append the test file name to the srcdir path and return the whole string */ +const char * +H5_get_srcdir_filename(const char *filename) +{ + const char *srcdir = H5_get_srcdir(); + + /* Check for error */ + if(NULL == srcdir) + return(NULL); + else { + /* Build path to test file */ + if((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(srcdir_testpath)) { + HDsnprintf(srcdir_testpath, sizeof(srcdir_testpath), "%s%s", srcdir, filename); + return(srcdir_testpath); + } /* end if */ + else + return(NULL); + } /* end else */ +} /* end H5_get_srcdir_filename() */ + |