2018-02-26 12:45:31 +08:00
|
|
|
/*********************************************************************
|
|
|
|
* Copyright 2018, UCAR/Unidata
|
|
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
* ********************************************************************/
|
|
|
|
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* 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 "config.h"
|
2018-07-20 03:07:13 +08:00
|
|
|
#include "hdf5internal.h"
|
2018-02-26 12:45:31 +08:00
|
|
|
#include <H5DSpublic.h> /* must be after nc4internal.h */
|
|
|
|
#include <H5Fpublic.h>
|
|
|
|
#include <H5LTpublic.h>
|
|
|
|
|
|
|
|
#include "netcdf.h"
|
|
|
|
#include "nc4internal.h"
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
|
|
|
|
#ifndef HDrealloc
|
|
|
|
#define HDrealloc(M,Z) realloc(M,Z)
|
|
|
|
#endif /* HDrealloc */
|
|
|
|
|
|
|
|
int
|
2018-06-22 21:08:09 +08:00
|
|
|
NC4_open_image_file(NC_FILE_INFO_T* h5)
|
2018-02-26 12:45:31 +08:00
|
|
|
{
|
|
|
|
int stat = NC_NOERR;
|
|
|
|
hid_t hdfid;
|
|
|
|
|
|
|
|
/* check arguments */
|
|
|
|
if(h5->mem.memio.memory == NULL || h5->mem.memio.size == 0)
|
|
|
|
{stat = NC_EINVAL; goto done;}
|
|
|
|
|
2018-09-05 01:27:47 +08:00
|
|
|
/* Figure out the image flags */
|
|
|
|
h5->mem.imageflags = 0;
|
2018-02-26 12:45:31 +08:00
|
|
|
if(h5->mem.locked) {
|
2018-09-05 01:27:47 +08:00
|
|
|
h5->mem.imageflags |= (H5LT_FILE_IMAGE_DONT_COPY | H5LT_FILE_IMAGE_DONT_RELEASE);
|
2018-02-26 12:45:31 +08:00
|
|
|
}
|
|
|
|
if(!h5->no_write)
|
2018-09-05 01:27:47 +08:00
|
|
|
h5->mem.imageflags |= H5LT_FILE_IMAGE_OPEN_RW;
|
2018-02-26 12:45:31 +08:00
|
|
|
|
|
|
|
/* Create the file but using our version of H5LTopen_file_image */
|
2018-05-04 11:02:32 +08:00
|
|
|
hdfid = NC4_image_init(h5);
|
2018-02-26 12:45:31 +08:00
|
|
|
if(hdfid < 0)
|
|
|
|
{stat = NC_EHDFERR; goto done;}
|
2018-07-20 03:07:13 +08:00
|
|
|
|
|
|
|
/* Remember HDF5 file identifier. */
|
|
|
|
((NC_HDF5_FILE_INFO_T *)h5->format_file_info)->hdfid = hdfid;
|
2018-02-26 12:45:31 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2018-06-22 21:08:09 +08:00
|
|
|
NC4_create_image_file(NC_FILE_INFO_T* h5, size_t initialsz)
|
2018-02-26 12:45:31 +08:00
|
|
|
{
|
|
|
|
int stat = NC_NOERR;
|
2018-09-05 01:27:47 +08:00
|
|
|
hid_t hdfid;
|
2018-02-26 12:45:31 +08:00
|
|
|
|
2018-05-04 11:02:32 +08:00
|
|
|
/* Create the file but using our version of H5LTopen_file_image */
|
|
|
|
h5->mem.created = 1;
|
|
|
|
h5->mem.initialsize = initialsz;
|
2018-09-05 01:27:47 +08:00
|
|
|
h5->mem.imageflags |= H5LT_FILE_IMAGE_OPEN_RW;
|
2018-05-04 11:02:32 +08:00
|
|
|
hdfid = NC4_image_init(h5);
|
|
|
|
if(hdfid < 0)
|
|
|
|
{stat = NC_EHDFERR; goto done;}
|
2018-07-20 03:07:13 +08:00
|
|
|
/* Remember HDF5 file identifier. */
|
|
|
|
((NC_HDF5_FILE_INFO_T *)h5->format_file_info)->hdfid = hdfid;
|
2018-02-26 12:45:31 +08:00
|
|
|
done:
|
|
|
|
return stat;
|
|
|
|
}
|