diff options
author | Patrick Lu <ptlu@hawkwind.ncsa.uiuc.edu> | 1999-04-29 17:44:36 (GMT) |
---|---|---|
committer | Patrick Lu <ptlu@hawkwind.ncsa.uiuc.edu> | 1999-04-29 17:44:36 (GMT) |
commit | 18d325e35fd17fbf24f4d31d63d025bb73052b7e (patch) | |
tree | 5251c51331229c8be27f347b5565bf7a057805b0 | |
parent | 2443c16bf0e93465b0bbebde5920b199fca5630c (diff) | |
download | hdf5-18d325e35fd17fbf24f4d31d63d025bb73052b7e.zip hdf5-18d325e35fd17fbf24f4d31d63d025bb73052b7e.tar.gz hdf5-18d325e35fd17fbf24f4d31d63d025bb73052b7e.tar.bz2 |
[svn-r1237] removed the path member in the search struct. replaced it with a fileindex
hi and lo. this number and the dev id will allow us to determine if the
file is currently open on NT
-rw-r--r-- | src/H5F.c | 16 | ||||
-rw-r--r-- | src/H5Flow.c | 59 | ||||
-rw-r--r-- | src/H5Fprivate.h | 13 | ||||
-rw-r--r-- | src/H5Fsec2.c | 56 |
4 files changed, 69 insertions, 75 deletions
@@ -509,13 +509,11 @@ H5F_compare_files(void * _obj, const void * _key) FUNC_ENTER(H5F_compare_files, FALSE); #if WIN32 - ret_value = stricmp(key->path, obj->shared->key.path); - if (ret_value){ - ret_value = FALSE; - } - else { - ret_value = TRUE; - } + + ret_value = (obj->shared->key.dev == key->dev && + obj->shared->key.fileindexhi == key->fileindexhi && + obj->shared->key.fileindexlo == key->fileindexlo); + #else ret_value = (obj->shared->key.dev == key->dev && obj->shared->key.ino == key->ino); @@ -1829,10 +1827,6 @@ H5F_close(H5F_t *f) "unable to flush cache"); } } -#ifdef WIN32 - /*free up the memory for path*/ - free(f->shared->key.path); -#endif /* * Destroy the H5F_t struct and decrement the reference count for the diff --git a/src/H5Flow.c b/src/H5Flow.c index caeb8a5..b3c0df1 100644 --- a/src/H5Flow.c +++ b/src/H5Flow.c @@ -493,43 +493,36 @@ H5F_low_access(const H5F_low_class_t *type, const char *name, if (key) { #ifdef WIN32 - /* - * Some windows specific types. the LPSTR is just a char* - */ - LPSTR pathbuf = NULL; - LPSTR *namebuf = NULL; - int bufsize = 0; - - - /* - * Gets the full path of the file name. the if statement below - * is to try to distinguish if we have the ablosute path already - */ - if ((*(name+1) != ':') && (*(name+2)!= '\\')){ - /* - * if the size of the buffer is too small it will return - * the appropriate size of the buffer not including the null - */ - bufsize = GetFullPathName(name,bufsize,pathbuf,namebuf); - if (bufsize != 0){ - pathbuf = malloc(sizeof(char) * (bufsize + 1)); - namebuf = malloc(sizeof(char) * (bufsize + 1)); - bufsize++; - GetFullPathName(name,bufsize,pathbuf,namebuf); - } else { - pathbuf = NULL; + + int fd; + HFILE filehandle; + struct _BY_HANDLE_FILE_INFORMATION fileinfo; + int results; + + + fd = HDopen(name,_O_RDONLY,0); + filehandle = _get_osfhandle(fd); + results = GetFileInformationByHandle(filehandle, &fileinfo); + + /*returns a 0 on failure*/ + + if (!results) { + ret_value = FALSE; + } + + else { + HDstat(name,&sb); + key->dev = sb.st_dev; + key->ino = 0; + key->fileindexhi = fileinfo.nFileIndexHigh; + key->fileindexlo = fileinfo.nFileIndexLow; } - } else { - pathbuf = malloc(strlen(name)); - strcpy(pathbuf,name); - } - key->path = pathbuf; - key->dev = 0; - key->ino = 0; + HDclose(fd); + + #else HDstat(name, &sb); - key->path = NULL; key->dev = sb.st_dev; key->ino = sb.st_ino; #endif diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index e8ab1de..93f3f64 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -302,7 +302,18 @@ typedef struct H5F_access_t { typedef struct H5F_search_t { dev_t dev; /* Device number containing file */ ino_t ino; /* Unique file number on device */ - char *path; /* File name used only in Win32 */ +#if WIN32 +/* + Specifies the low-order word of a unique identifier associated with the file. + This identifier and the volume serial number uniquely identify a file. This number + may change when the system is restarted or when the file is opened. After a process + opens a file, the identifier is constant until the file is closed. An application can + use this identifier and the volume serial number to determine whether two handles refer + to the same file. +*/ + int fileindexlo; + int fileindexhi; +#endif } H5F_search_t; /* For determining what the last file operation was */ diff --git a/src/H5Fsec2.c b/src/H5Fsec2.c index 476d292..add8e1f 100644 --- a/src/H5Fsec2.c +++ b/src/H5Fsec2.c @@ -97,41 +97,37 @@ H5F_sec2_open(const char *name, const H5F_access_t UNUSED *access_parms, if (key) { #if WIN32 - /* - * some windows specific types. the LPSTR is just a char* - */ - LPSTR pathbuf = NULL; - LPSTR *namebuf = NULL; - int bufsize = 0; - /* - * gets the full path of the file name. the if statement below is to - * try to distinguish if we have the ablosute path already - */ - if ((*(name+1) != ':') && (*(name+2)!= '\\')){ - /* - * if the size of the buffer is too small it will return - * the appropriate size of the buffer not including the null - */ - bufsize = GetFullPathName(name,bufsize,pathbuf,namebuf); - if (bufsize != 0){ - pathbuf = malloc(sizeof(char) * (bufsize + 1)); - namebuf = malloc(sizeof(char) * (bufsize + 1)); - bufsize++; - GetFullPathName(name,bufsize,pathbuf,namebuf); - } else { - pathbuf = NULL; - } - } else { - pathbuf = malloc(strlen(name)); - strcpy(pathbuf,name); + int fd; + HFILE filehandle; + struct _BY_HANDLE_FILE_INFORMATION fileinfo; + int results; + + + fd = HDopen(name,_O_RDONLY,0); + filehandle = _get_osfhandle(fd); + results = GetFileInformationByHandle(filehandle, &fileinfo); + + /*returns a 0 on failure*/ + + if (!results) { + lf = NULL; + } + + else { + HDstat(name,&sb); + key->dev = sb.st_dev; + key->ino = 0; + key->fileindexhi = fileinfo.nFileIndexHigh; + key->fileindexlo = fileinfo.nFileIndexLow; } - key->path = pathbuf; + + HDclose(fd); + #else - key->path = NULL; -#endif key->dev = sb.st_dev; key->ino = sb.st_ino; +#endif } FUNC_LEAVE(lf); } |