summaryrefslogtreecommitdiffstats
path: root/src/H5system.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-12-01 13:39:05 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-12-01 13:39:05 (GMT)
commit1bc79f977be67f734a44fd237be6f05b5fb25f53 (patch)
tree3cd0716146f86ede9c4fb3b0d1d70155bd711cf9 /src/H5system.c
parent77b493eea3b68cd7348be16488c68efb44687e2d (diff)
downloadhdf5-1bc79f977be67f734a44fd237be6f05b5fb25f53.zip
hdf5-1bc79f977be67f734a44fd237be6f05b5fb25f53.tar.gz
hdf5-1bc79f977be67f734a44fd237be6f05b5fb25f53.tar.bz2
[svn-r17939] Description:
Handle external links from symlinked files by adding another check to look for "child" files for links from the actual location of the "parent" file, instead of from the location of the symlink. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5system.c')
-rw-r--r--src/H5system.c89
1 files changed, 49 insertions, 40 deletions
diff --git a/src/H5system.c b/src/H5system.c
index 36ec1c1..9d93d9c 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -627,28 +627,21 @@ HDgettimeofday(struct timeval *tv, void *tz)
#endif
-/*
- *-------------------------------------------------------------------------
- *
+/*-------------------------------------------------------------------------
* Function: H5_build_extpath
*
- * Purpose: To build the path for later searching of target file for external link.
- * This path can be either:
- * 1. The absolute path of NAME
+ * Purpose: To build the path for later searching of target file for external
+ * link. This path can be either:
+ * 1. The absolute path of NAME
* or
- * 2. The current working directory + relative path of NAME
+ * 2. The current working directory + relative path of NAME
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Vailin Choi
* April 2, 2008
- * Modifications: 2nd Oct, 2008; Vailin Choi
- * Remove compiler warning for "if condition"
- *
- * Raymond Lu
- * 14 Jan. 2009
- * Add support for OpenVMS pathname
+ *
*-------------------------------------------------------------------------
*/
#define MAX_PATH_LEN 1024
@@ -656,14 +649,14 @@ HDgettimeofday(struct timeval *tv, void *tz)
herr_t
H5_build_extpath(const char *name, char **extpath/*out*/)
{
- char *full_path=NULL, *ptr=NULL;
- char *retcwd=NULL, *cwdpath=NULL, *new_name=NULL;
- int drive;
- size_t cwdlen, path_len;
+ char *full_path = NULL; /* Pointer to the full path, as built or passed in */
+ char *cwdpath = NULL; /* Pointer to the current working directory path */
+ char *new_name = NULL; /* Pointer to the name of the file */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5_build_extpath)
+ /* Clear external path pointer to begin with */
*extpath = NULL;
/*
@@ -672,14 +665,18 @@ H5_build_extpath(const char *name, char **extpath/*out*/)
* OpenVMS: <disk name>$<partition>:[path]<file name>
* i.g. SYS$SYSUSERS:[LU.HDF5.SRC]H5system.c
*/
- if (CHECK_ABSOLUTE(name)) {
- if ((full_path=H5MM_strdup(name)) == NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- } else { /* relative pathname */
- if (NULL == (cwdpath = (char *)H5MM_malloc(MAX_PATH_LEN)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- if (NULL == (new_name = (char *)H5MM_strdup(name)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ if(CHECK_ABSOLUTE(name)) {
+ if(NULL == (full_path = (char *)H5MM_strdup(name)))
+ HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed")
+ } /* end if */
+ else { /* relative pathname */
+ char *retcwd;
+ int drive;
+
+ if(NULL == (cwdpath = (char *)H5MM_malloc(MAX_PATH_LEN)))
+ HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed")
+ if(NULL == (new_name = (char *)H5MM_strdup(name)))
+ HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed")
/*
* Windows: name[0-1] is "<drive-letter>:"
@@ -687,29 +684,35 @@ H5_build_extpath(const char *name, char **extpath/*out*/)
* Unix: does not apply
* OpenVMS: does not apply
*/
- if (CHECK_ABS_DRIVE(name)) {
+ if(CHECK_ABS_DRIVE(name)) {
drive = name[0] - 'A' + 1;
retcwd = HDgetdcwd(drive, cwdpath, MAX_PATH_LEN);
HDstrcpy(new_name, &name[2]);
+ } /* end if */
/*
* Windows: name[0] is a '/' or '\'
* Get current drive
* Unix: does not apply
* OpenVMS: does not apply
*/
- } else if (CHECK_ABS_PATH(name) && ((drive=HDgetdrive()) != 0)) {
+ else if(CHECK_ABS_PATH(name) && (0 != (drive = HDgetdrive()))) {
sprintf(cwdpath, "%c:%c", (drive+'A'-1), name[0]);
retcwd = cwdpath;
HDstrcpy(new_name, &name[1]);
- } else /* totally relative for Unix, Windows, and OpenVMS: get current working directory */
+ }
+ /* totally relative for Unix, Windows, and OpenVMS: get current working directory */
+ else
retcwd = HDgetcwd(cwdpath, MAX_PATH_LEN);
- if (retcwd != NULL) {
+ if(retcwd != NULL) {
+ size_t cwdlen;
+ size_t path_len;
+
cwdlen = HDstrlen(cwdpath);
HDassert(cwdlen);
path_len = cwdlen + HDstrlen(new_name) + 2;
- if (NULL == (full_path = (char *)H5MM_malloc(path_len)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ if(NULL == (full_path = (char *)H5MM_malloc(path_len)))
+ HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed")
HDstrcpy(full_path, cwdpath);
#ifdef H5_VMS
@@ -721,30 +724,36 @@ H5_build_extpath(const char *name, char **extpath/*out*/)
*/
if(new_name[0] == '[') {
char *tmp = new_name;
- full_path[cwdlen-1] = '\0';
+ full_path[cwdlen - 1] = '\0';
HDstrcat(full_path, ++tmp);
- } else
+ } /* end if */
+ else
HDstrcat(full_path, new_name);
#else
- if (!CHECK_DELIMITER(cwdpath[cwdlen-1]))
+ if(!CHECK_DELIMITER(cwdpath[cwdlen - 1]))
HDstrcat(full_path, DIR_SEPS);
HDstrcat(full_path, new_name);
#endif
- }
- }
+ } /* end if */
+ } /* end else */
/* strip out the last component (the file name itself) from the path */
- if (full_path) {
+ if(full_path) {
+ char *ptr = NULL;
+
GET_LAST_DELIMITER(full_path, ptr)
HDassert(ptr);
*++ptr = '\0';
*extpath = full_path;
- }
+ } /* end if */
done:
- if (cwdpath)
+ /* Release resources */
+ if(cwdpath)
H5MM_xfree(cwdpath);
- if (new_name)
+ if(new_name)
H5MM_xfree(new_name);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* H5_build_extpath() */
+