summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5F.c41
-rw-r--r--src/H5Fpkg.h1
-rw-r--r--src/H5Fprivate.h3
-rw-r--r--src/H5Lexternal.c200
-rw-r--r--src/H5config.h.in3
-rw-r--r--src/H5private.h47
-rw-r--r--src/H5system.c96
7 files changed, 360 insertions, 31 deletions
diff --git a/src/H5F.c b/src/H5F.c
index cb9e3b8..80c28bc 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -978,6 +978,9 @@ done:
* Programmer: Robb Matzke
* matzke@llnl.gov
* Jul 18 1997
+ * Modifications:
+ * Vailin Choi, April 2, 2008
+ * Free f->extpath
*
*-------------------------------------------------------------------------
*/
@@ -1068,6 +1071,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id)
/* Free the non-shared part of the file */
f->name = H5MM_xfree(f->name);
+ f->extpath = H5MM_xfree(f->extpath);
f->mtab.child = H5MM_xfree(f->mtab.child);
f->mtab.nalloc = 0;
if(H5FO_top_dest(f) < 0)
@@ -1078,6 +1082,8 @@ H5F_dest(H5F_t *f, hid_t dxpl_id)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_dest() */
+
+
/*-------------------------------------------------------------------------
* Function: H5F_open
@@ -1157,6 +1163,9 @@ H5F_dest(H5F_t *f, hid_t dxpl_id)
* Modified H5F_flush call to take one flag instead of
* multiple Boolean flags.
*
+ * Vailin Choi, 2008-04-02
+ * To formulate path for later searching of target file for external link
+ * via H5_build_extpath().
*-------------------------------------------------------------------------
*/
H5F_t *
@@ -1353,6 +1362,10 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match")
} /* end if */
+ /* formulate the absolute path for later search of target file for external link */
+ if (H5_build_extpath(name, &file->extpath) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build extpath")
+
/* Success */
ret_value = file;
@@ -2140,6 +2153,33 @@ H5F_get_intent(const H5F_t *f)
/*-------------------------------------------------------------------------
+ * Function: H5F_get_extpath
+ *
+ * Purpose: Retrieve the file's 'extpath' flags
+ * This is used by H5L_extern_traverse() to retrieve the main file's location
+ * when searching the target file.
+ *
+ * Return: 'extpath' on success/abort on failure (shouldn't fail)
+ *
+ * Programmer: Vailin Choi, April 2, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+char *
+H5F_get_extpath(const H5F_t *f)
+{
+ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_extpath)
+
+ HDassert(f);
+
+ FUNC_LEAVE_NOAPI(f->extpath)
+} /* end H5F_get_extpath() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5F_sizeof_addr
*
* Purpose: Quick and dirty routine to retrieve the size of the file's size_t
@@ -3618,4 +3658,3 @@ H5Fget_info(hid_t obj_id, H5F_info_t *finfo)
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Fget_info() */
-
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 3f10e1a..288ef8a 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -142,6 +142,7 @@ typedef struct H5F_mtab_t {
struct H5F_t {
unsigned intent; /* The flags passed to H5F_open()*/
char *name; /* Name used to open file */
+ char *extpath; /* Path for searching target external link file */
H5F_file_t *shared; /* The shared file info */
unsigned nopen_objs; /* Number of open object headers*/
H5FO_t *obj_count; /* # of time each object is opened through top file structure */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 1044b14..27b45f2 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -265,6 +265,7 @@ typedef struct H5F_t H5F_t;
#define H5F_GC_REF(F) ((F)->shared->gc_ref)
#define H5F_USE_LATEST_FORMAT(F) ((F)->shared->latest_format)
#define H5F_INTENT(F) ((F)->intent)
+#define H5F_EXTPATH(F) ((F)->extpath)
#define H5F_GET_FC_DEGREE(F) ((F)->shared->fc_degree)
#define H5F_STORE_MSG_CRT_IDX(F) ((F)->shared->store_msg_crt_idx)
#define H5F_GET_FILENO(F,FILENUM) ((FILENUM) = (F)->shared->lf->fileno)
@@ -284,6 +285,7 @@ typedef struct H5F_t H5F_t;
#define H5F_GC_REF(F) (H5F_gc_ref(F))
#define H5F_USE_LATEST_FORMAT(F) (H5F_use_latest_format(F))
#define H5F_INTENT(F) (H5F_get_intent(F))
+#define H5F_EXTPATH(F) (H5F_get_extpath(F))
#define H5F_GET_FC_DEGREE(F) (H5F_get_fc_degree(F))
#define H5F_STORE_MSG_CRT_IDX(F) (H5F_store_msg_crt_idx(F))
#define H5F_GET_FILENO(F,FILENUM) (H5F_get_filenum((F), &(FILENUM)))
@@ -417,6 +419,7 @@ H5_DLL herr_t H5F_try_close(H5F_t *f);
H5_DLL hid_t H5F_get_driver_id(const H5F_t *f);
H5_DLL hid_t H5F_get_access_plist(H5F_t *f);
H5_DLL unsigned H5F_get_intent(const H5F_t *f);
+H5_DLL char *H5F_get_extpath(const H5F_t *f);
H5_DLL herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum);
H5_DLL hid_t H5F_get_id(H5F_t *file);
H5_DLL unsigned H5F_get_obj_count(const H5F_t *f, unsigned types);
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c
index 5a8eb33..4e355bb 100644
--- a/src/H5Lexternal.c
+++ b/src/H5Lexternal.c
@@ -76,6 +76,81 @@ H5L_init_extern_interface(void)
} /* H5L_init_extern_interface() */
+
+/*--------------------------------------------------------------------------
+ * Function: H5L_getenv_prefix_name --
+ *
+ * Purpose: Get the first pathname in the list of pathnames stored in ENV_PREFIX,
+ * which is separated by the environment delimiter.
+ * ENV_PREFIX is modified to point to the remaining pathnames
+ * in the list.
+ *
+ * Return: A pointer to a pathname
+ *
+ * Programmer: Vailin Choi, April 2, 2008
+ *
+--------------------------------------------------------------------------*/
+static char *
+H5L_getenv_prefix_name(char **env_prefix/*in,out*/)
+{
+ char *retptr=NULL;
+ char *strret=NULL;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5L_getenv_prefix_name)
+
+ strret = HDstrchr(*env_prefix, COLON_SEPC);
+ if (strret == NULL) {
+ retptr = *env_prefix;
+ *env_prefix = strret;
+ } else {
+ retptr = *env_prefix;
+ *env_prefix = strret + 1;
+ *strret = '\0';
+ }
+ return(retptr);
+ FUNC_LEAVE_NOAPI(retptr)
+}
+
+
+/*--------------------------------------------------------------------------
+ * Function: H5L_build_name
+ *
+ * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi, April 2, 2008
+ *
+--------------------------------------------------------------------------*/
+static herr_t
+H5L_build_name(char *prefix, char *file_name, char **full_name/*out*/)
+{
+ size_t prefix_len; /* length of prefix */
+ size_t fname_len; /* Length of external link file name */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5L_build_name)
+
+ prefix_len = HDstrlen(prefix);
+ fname_len = HDstrlen(file_name);
+
+ /* Allocate a buffer to hold the filename + prefix + possibly the delimiter + terminating null byte */
+ if(NULL == (*full_name = H5MM_malloc(prefix_len + fname_len + 2)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate filename buffer")
+
+ /* Copy the prefix into the buffer */
+ HDstrcpy(*full_name, prefix);
+ if (!CHECK_DELIMITER(prefix[prefix_len-1]))
+ HDstrcat(*full_name, DIR_SEPS);
+
+ /* Add the external link's filename to the prefix supplied */
+ HDstrcat(*full_name, file_name);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5L_build_name() */
+
+
/*-------------------------------------------------------------------------
* Function: H5L_extern_traverse
*
@@ -92,6 +167,10 @@ H5L_init_extern_interface(void)
*
* Programmer: James Laird
* Monday, July 10, 2006
+ * Modifications:
+ * Vailin Choi, April 2, 2008
+ * Add handling to search for the target file
+ * See description in RM: H5Lcreate_external
*
*-------------------------------------------------------------------------
*/
@@ -114,6 +193,11 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
hid_t ext_obj = -1; /* ID for external link's object */
hid_t ret_value; /* Return value */
+ char *tempname=NULL, *ptr=NULL, *extpath=NULL;
+ char *env_prefix=NULL, *tmp_env_prefix=NULL;
+ char *out_prefix_name=NULL, *pp=NULL;
+
+
FUNC_ENTER_NOAPI(H5L_extern_traverse, FAIL)
/* Sanity checks */
@@ -135,28 +219,6 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
- /* Get the current prefix */
- if(H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix")
-
- /* Check for prefix being set, if so, prepend it to the filename */
- if(my_prefix) {
- size_t prefix_len = HDstrlen(my_prefix);
-
- /* Allocate a buffer to hold the filename plus prefix */
- if(NULL == (full_name = H5MM_malloc(prefix_len + fname_len + 1)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate filename buffer")
-
- /* Copy the prefix into the buffer */
- HDstrcpy(full_name, my_prefix);
-
- /* Add the external link's filename to the prefix supplied */
- HDstrcat(full_name, (const char *)p);
-
- /* Point to name w/prefix */
- file_name = full_name;
- } /* end if */
-
/* Get the location for the group holding the external link */
if(H5G_loc(cur_group, &loc) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get object location")
@@ -183,10 +245,92 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree")
} /* end if */
- /* Open the external file */
- /* (extra work with file intent to mask off inappropriate flags) */
- if(NULL == (ext_file = H5F_open(file_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY), H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)))
- HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, FAIL, "unable to open external file")
+ /*
+ * Start searching for the target file
+ */
+ if ((tempname=H5MM_strdup(file_name)) == NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /* target file_name is an absolute pathname: see RM for detailed description */
+ if (CHECK_ABSOLUTE(file_name) || CHECK_ABS_PATH(file_name)) {
+ if(NULL == (ext_file = H5F_open(file_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY),
+ H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) {
+ H5E_clear_stack(NULL);
+ /* get last component of file_name */
+ GET_LAST_DELIMITER(file_name, ptr)
+ HDassert(ptr);
+ HDstrcpy(tempname, ++ptr);
+ }
+ } else if (CHECK_ABS_DRIVE(file_name)) {
+ if(NULL == (ext_file = H5F_open(file_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY),
+ H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) {
+ H5E_clear_stack(NULL);
+ /* strip "<drive-letter>:" */
+ HDstrcpy(tempname, &file_name[2]);
+ }
+ }
+
+ /* try searching from paths set in the environment variable */
+ if ((ext_file == NULL) && (env_prefix=HDgetenv("HDF5_EXT_PREFIX"))) {
+
+ tmp_env_prefix = H5MM_strdup(env_prefix);
+ pp = tmp_env_prefix;
+
+ while ((tmp_env_prefix) && (*tmp_env_prefix)) {
+ out_prefix_name = H5L_getenv_prefix_name(&tmp_env_prefix/*in,out*/);
+ if ((out_prefix_name) && (*out_prefix_name)) {
+
+ if (H5L_build_name(out_prefix_name, tempname, &full_name/*out*/) < 0)
+ HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename")
+
+ ext_file = H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY),
+ H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id);
+ if (full_name)
+ H5MM_xfree(full_name);
+ if (ext_file != NULL)
+ break;
+ H5E_clear_stack(NULL);
+ }
+ } /* end while */
+ if (pp)
+ H5MM_xfree(pp);
+ }
+
+ /* try searching from property list */
+ if (ext_file == NULL) {
+ if(H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix")
+ if (my_prefix) {
+ if (H5L_build_name(my_prefix, tempname, &full_name/*out*/) < 0)
+ HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename")
+ if ((ext_file=H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY),
+ H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL)
+ H5E_clear_stack(NULL);
+ if (full_name)
+ H5MM_xfree(full_name);
+ }
+ }
+
+ /* try searching from main file's "extpath":see description in H5F_open() & H5_build_extpath() */
+ if ((ext_file == NULL) && (extpath=H5F_EXTPATH(loc.oloc->file))) {
+ if (H5L_build_name(extpath, tempname, &full_name/*out*/) < 0)
+ HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename")
+ if ((ext_file = H5F_open(full_name, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY),
+ H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL)
+ H5E_clear_stack(NULL);
+ if (full_name)
+ H5MM_xfree(full_name);
+ }
+
+ /* try the relative file_name stored in tempname */
+ if (ext_file == NULL) {
+ if ((ext_file=H5F_open(tempname, ((intent & H5F_ACC_RDWR) ? H5F_ACC_RDWR : H5F_ACC_RDONLY),
+ H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)) == NULL)
+ HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, FAIL, "unable to open external file")
+ }
+
+ if (tempname)
+ H5MM_xfree(tempname);
/* Increment the number of open objects, to hold the file open */
H5F_incr_nopen_objs(ext_file);
@@ -219,10 +363,6 @@ done:
if(ext_file && H5F_try_close(ext_file) < 0)
HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, FAIL, "problem closing external file")
- /* Free full_name if it's been allocated */
- if(full_name)
- H5MM_xfree(full_name);
-
/* Close object if it's open and something failed */
if(ret_value < 0 && ext_obj >= 0 && H5I_dec_ref(ext_obj) < 0)
HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for external object")
diff --git a/src/H5config.h.in b/src/H5config.h.in
index 5c767ef..77a3b23 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -368,6 +368,9 @@
/* Define to 1 if you have the `waitpid' function. */
#undef HAVE_WAITPID
+/* Define if your system has window style path name. */
+#undef HAVE_WINDOW_PATH
+
/* Define to 1 if you have the <winsock.h> header file. */
#undef HAVE_WINSOCK_H
diff --git a/src/H5private.h b/src/H5private.h
index 11f3037..734290d 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -638,9 +638,19 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
#define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F)
#define HDgetc(F) getc(F)
#define HDgetchar() getchar()
+#ifdef _WIN32
+#define HDgetcwd(S,Z) _getcwd(S,Z)
+#define HDgetdcwd(D,S,Z) _getdcwd(D,S,Z)
+#define HDgetdrive() _getdrive()
+#else
#define HDgetcwd(S,Z) getcwd(S,Z)
+#define HDgetdcwd(D,S,Z) getcwd(S,Z)
+#define HDgetdrive() 0
+#endif
#define HDgetegid() getegid()
#define HDgetenv(S) getenv(S)
+#define HDsetenv(S,V,O) setenv(S,V,O)
+#define HDunsetenv(S) unsetenv(S)
#define HDgeteuid() geteuid()
#define HDgetgid() getgid()
#define HDgetgrgid(G) getgrgid(G)
@@ -911,6 +921,43 @@ extern char *strdup(const char *s);
#endif /* _WIN32 */
+#ifdef H5_HAVE_WINDOW_PATH
+
+/* directory delimiter for Windows: slash and backslash are acceptable on Windows */
+#define DIR_SLASH_SEPC '/'
+#define DIR_SEPC '\\'
+#define DIR_SEPS "\\"
+#define CHECK_DELIMITER(SS) ((SS == DIR_SEPC)||(SS == DIR_SLASH_SEPC))
+#define CHECK_ABSOLUTE(NAME) (((isalpha(NAME[0])) && (NAME[1] == ':') && CHECK_DELIMITER(NAME[2]))
+#define CHECK_ABS_DRIVE(NAME) ((isalpha(NAME[0])) && (NAME[1] == ':'))
+#define CHECK_ABS_PATH(NAME) (CHECK_DELIMITER(NAME[0]))
+
+#define GET_LAST_DELIMITER(NAME, ptr) { \
+ char *slash, *backslash; \
+ slash = strrchr(NAME, DIR_SLASH_SEPC); \
+ backslash = strrchr(NAME, DIR_SEPC); \
+ if (backslash > slash) \
+ (ptr = backslash); \
+ else \
+ (ptr = slash); \
+}
+
+
+#else
+
+#define DIR_SEPC '/'
+#define DIR_SEPS "/"
+#define CHECK_DELIMITER(SS) (SS == DIR_SEPC)
+#define CHECK_ABSOLUTE(NAME) (CHECK_DELIMITER(*NAME))
+#define CHECK_ABS_DRIVE(NAME) (0)
+#define CHECK_ABS_PATH(NAME) (0)
+#define GET_LAST_DELIMITER(NAME, ptr) ptr = strrchr(NAME, DIR_SEPC);
+
+#endif
+
+#define COLON_SEPC ':'
+H5_DLL herr_t H5_build_extpath(const char *, char **/*out*/);
+
/*
* These macros check whether debugging has been requested for a certain
diff --git a/src/H5system.c b/src/H5system.c
index 5eae11d..d65103a 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -35,6 +35,8 @@
#include "H5private.h" /* Generic Functions */
#include "H5Fprivate.h" /* File access */
#include "H5MMprivate.h" /* Memory management */
+#include "H5Eprivate.h"
+
/****************/
@@ -578,4 +580,98 @@ HDremove_all(const char *fname)
}
#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
+ * or
+ * 2. The current working directory + relative path of NAME
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi
+ * April 2, 2008
+ */
+#define MAX_PATH_LEN 1024
+
+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;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5_build_extpath)
+
+ *extpath = NULL;
+
+ /*
+ * Unix: name[0] is a "/"
+ * Windows: name[0-2] is "<drive letter>:\" or "<drive-letter>:/"
+ */
+ 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 ((cwdpath=H5MM_malloc(MAX_PATH_LEN)) == NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ if ((new_name=H5MM_strdup(name)) == NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /*
+ * Windows: name[0-1] is "<drive-letter>:"
+ * Get current working directory on the drive specified in NAME
+ * Unix: does not apply
+ */
+ if (CHECK_ABS_DRIVE(name)) {
+ drive = name[0] - 'A' + 1;
+ retcwd = HDgetdcwd(drive, cwdpath, MAX_PATH_LEN);
+ HDstrcpy(new_name, &name[2]);
+ /*
+ * Windows: name[0] is a '/' or '\'
+ * Get current drive
+ * Unix: does not apply
+ */
+ } else if (CHECK_ABS_PATH(name) && (drive=HDgetdrive())) {
+ sprintf(cwdpath, "%c:%c", (drive+'A'-1), name[0]);
+ retcwd = cwdpath;
+ HDstrcpy(new_name, &name[1]);
+ } else /* totally relative for both Unix and Windows: get current working directory */
+ retcwd = HDgetcwd(cwdpath, MAX_PATH_LEN);
+
+ if (retcwd != NULL) {
+ cwdlen = HDstrlen(cwdpath);
+ HDassert(cwdlen);
+ path_len = cwdlen + HDstrlen(new_name) + 2;
+ if ((full_path=H5MM_malloc(path_len)) == NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ HDstrcpy(full_path, cwdpath);
+ if (!CHECK_DELIMITER(cwdpath[cwdlen-1]))
+ HDstrcat(full_path, DIR_SEPS);
+ HDstrcat(full_path, new_name);
+ }
+ }
+
+ /* strip out the last component (the file name itself) from the path */
+ if (full_path) {
+ GET_LAST_DELIMITER(full_path, ptr)
+ HDassert(ptr);
+ *++ptr = '\0';
+ *extpath = full_path;
+ }
+done:
+ if (cwdpath)
+ H5MM_xfree(cwdpath);
+ if (new_name)
+ H5MM_xfree(new_name);
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5_build_extpath() */