NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
NOTE: The netcdf-hdf
mailing list is no longer active. The list archives are made available for historical reasons.
Hi Ed, > I have a question about opening the same file twice. I am finding that > I can open the same file twice, unless I first open it for read-only > access, and the try and open it for read-write access. > > The code below demonstrates. Do I have it correctly? Does the same > rule apply for parallel situation? (That is, does the writer always > have to open the file first?) Yes. Since the library uses only one system call to open the file, it can't "upgrade" a read-only file to one that permits writing. Quincey > Thanks! > > Ed > > > /* Confirm that the same file can be opened twice at the same time, > * for read only access. */ > if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR; > if ((fileid2 = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR; > if (H5Fclose(fileid) < 0) ERR; > if (H5Fclose(fileid2) < 0) ERR; > > /* Once open for read only access, the file can't be opened again > * for write access. */ > if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR; > if ((fileid2 = H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) >= 0) ERR; > if (H5Fclose(fileid) < 0) ERR; > > /* But you can open the file for read/write access, and then open > * it again for read only access. */ > if ((fileid2 = H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR; > if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR; > if (H5Fclose(fileid) < 0) ERR; > if (H5Fclose(fileid2) < 0) ERR; > > > > -- > Ed Hartnett -- ed@xxxxxxxxxxxxxxxx >
netcdf-hdf
archives: