error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "listvarinfile", 1));
end
- //check file format
if is_hdf5_file(filename) then
- [a,b,c,d] = listvar_in_hdf5(filename);
+ listvarFunction = listvar_in_hdf5;
else
- [a,b,c,d] = %_listvarinfile(filename);
+ listvarFunction = %_listvarinfile;
end
- varargout = list(a,b,c,d);
+ //check output argument count
+ if lhs == 1 then
+ a = listvarFunction(filename);
+ varargout = list(a);
+ elseif lhs == 2 then
+ [a,b] = listvarFunction(filename);
+ varargout = list(a,b);
+ elseif lhs == 3 then
+ [a,b,c] = listvarFunction(filename);
+ varargout = list(a,b,c);
+ elseif lhs == 4 then
+ [a,b,c,d] = listvarFunction(filename);
+ varargout = list(a,b,c,d);
+ end
endfunction
HDF5_SCILAB_IMPEXP int writePolyMatrix(int _iFile, char* _pstDatasetName, char* _pstVarName, int _iRows, int _iCols, int* _piNbCoef, double** _pdblData);
HDF5_SCILAB_IMPEXP int writePolyComplexMatrix(int _iFile, char* _pstDatasetName, char* _pstVarName, int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
-HDF5_SCILAB_IMPEXP int writeInterger8Matrix(int _iFile, char* _pstDatasetName, int _iRows, int _iCols, char* _piData8);
-HDF5_SCILAB_IMPEXP int writeInterger16Matrix(int _iFile, char* _pstDatasetName, int _iRows, int _iCols, short* _piData16);
-HDF5_SCILAB_IMPEXP int writeInterger32Matrix(int _iFile, char* _pstDatasetName, int _iRows, int _iCols, int* _piData32);
-HDF5_SCILAB_IMPEXP int writeInterger64Matrix(int _iFile, char* _pstDatasetName, int _iRows, int _iCols, long long* _piData64);
+HDF5_SCILAB_IMPEXP int writeInteger8Matrix(int _iFile, char* _pstDatasetName, int _iRows, int _iCols, char* _piData8);
+HDF5_SCILAB_IMPEXP int writeInteger16Matrix(int _iFile, char* _pstDatasetName, int _iRows, int _iCols, short* _piData16);
+HDF5_SCILAB_IMPEXP int writeInteger32Matrix(int _iFile, char* _pstDatasetName, int _iRows, int _iCols, int* _piData32);
+HDF5_SCILAB_IMPEXP int writeInteger64Matrix(int _iFile, char* _pstDatasetName, int _iRows, int _iCols, long long* _piData64);
HDF5_SCILAB_IMPEXP int writeUnsignedInterger8Matrix(int _iFile, char* _pstDatasetName, int _iRows, int _iCols, unsigned char* _piData8);
HDF5_SCILAB_IMPEXP int writeUnsignedInterger16Matrix(int _iFile, char* _pstDatasetName, int _iRows, int _iCols, unsigned short* _piData16);
#include "expandPathVariable.h"
#include "h5_fileManagement.h"
#include "h5_writeDataToFile.h"
+#include "h5_readDataFromFile.h"
#include "freeArrayOfString.h"
#ifdef _MSC_VER
#include "strdup_windows.h"
char** pstNameList = NULL;
char *pstFileName = NULL;
bool bExport = false;
+ int iStartVarName = 1;
+ bool bAppendMode = false;
SciErr sciErr;
- CheckRhs(1, 100000);//output parameter
+ CheckInputArgumentAtLeast(pvApiCtx, 2);
+ CheckLhs(0, 1);
#ifndef _MSC_VER
forceJHDF5load();
#endif
- /*get input data*/
- if (Rhs < 2)
- {
- Scierror(999, _("%s: Wrong number of input argument(s): At most %d expected.\n"), fname, 2);
- return 0;
- }
-
pstNameList = (char**)MALLOC(sizeof(char*) * Rhs);
iNbVar = extractVarNameList(1, Rhs, pstNameList);
if (iNbVar == 0)
{
FREE(pstNameList);
- return 0;
+ return 1;
}
- piAddrList = (int**)MALLOC(sizeof(int*) * (iNbVar - 1));
- for (int i = 0 ; i < Rhs - 1 ; i++)
+ if(strcmp(pstNameList[1], "-append") == 0)
{
- sciErr = getVarAddressFromName(pvApiCtx, pstNameList[i + 1], &piAddrList[i]);
+ bAppendMode = true;
+ iStartVarName = 2;
+ }
+
+ piAddrList = (int**)MALLOC(sizeof(int*) * (iNbVar - iStartVarName));
+ for (int i = iStartVarName ; i < Rhs ; i++)
+ {
+ sciErr = getVarAddressFromName(pvApiCtx, pstNameList[i], &piAddrList[i - iStartVarName]);
if (sciErr.iErr)
{
- // i+1 = i for filename + 1 because starting arg number is 1 for human being
- Scierror(999, _("%s: Wrong value for input argument #%d: Defined variable expected.\n"), fname, i + 2);
+ Scierror(999, _("%s: Wrong value for input argument #%d: Defined variable expected.\n"), fname, i + 1);
printError(&sciErr, 0);
- return 0;
+ return 1;
}
}
+ //check append option
+
iLevel = 0;
// open hdf5 file
pstFileName = expandPathVariable(pstNameList[0]);
- int iH5File = createHDF5File(pstFileName);
+ int iH5File = 0;
+ if(bAppendMode)
+ {
+ iH5File = openHDF5File(pstFileName);
+ if(iH5File < 0)
+ {
+ iH5File = createHDF5File(pstFileName);
+ }
+ }
+ else
+ {
+ iH5File = createHDF5File(pstFileName);
+ }
+
if (iH5File < 0)
{
Scierror(999, _("%s: Cannot open file %s.\n"), fname, pstNameList[0]);
}
- return 0;
+ return 1;
+ }
+
+
+ if(bAppendMode)
+ {
+ //check if variable already exists
+ int iNbItem = getVariableNames(iH5File, NULL);
+ if(iNbItem)
+ {
+ char **pstVarNameList = (char **)MALLOC(sizeof(char *) * iNbItem);
+
+ iNbItem = getVariableNames(iH5File, pstVarNameList);
+
+ //import all data
+ for(int i = 0 ; i < iNbItem ; i++)
+ {
+ for(int j = 0 ; j < Rhs - iStartVarName; j++)
+ {
+ if(strcmp(pstVarNameList[i], pstNameList[j + iStartVarName]) == 0)
+ {
+
+ Scierror(999, _("%s: Variable \'%s\' already exists in file \'%s\'."), fname, pstVarNameList[i], pstNameList[0]);
+ return 1;
+ }
+ }
+ FREE(pstVarNameList[i]);
+ }
+ FREE(pstVarNameList);
+ }
}
// export data
- for (int i = 0 ; i < Rhs - 1; i++)
+ for (int i = 0 ; i < Rhs - iStartVarName; i++)
{
- bExport = export_data(iH5File, piAddrList[i], pstNameList[i + 1]);
+ bExport = export_data(iH5File, piAddrList[i], pstNameList[i + iStartVarName]);
if (bExport == false)
{
break;
if (sciErr.iErr)
{
printError(&sciErr, 0);
- return 0;
+ return 1;
}
if (bExport == true)
piReturn[0] = 0;
}
+
+ //free memory
+ for(int i = 0 ; i < Rhs ; i++)
+ {
+ FREE(pstNameList[i]);
+ }
+ FREE(pstNameList);
+
+ FREE(piAddrList);
+
LhsVar(1) = Rhs + 1;
PutLhsVar();
return 0;
bReturn = export_void(_iH5File, _piVar, _pstName);
break;
}
+
+ default :
+ {
+ bReturn = false;
+ break;
+ }
}
return bReturn;
}
printError(&sciErr, 0);
return false;
}
- iRet = writeInterger8Matrix(_iH5File, _pstName, iRows, iCols, (char*)piData);
+ iRet = writeInteger8Matrix(_iH5File, _pstName, iRows, iCols, (char*)piData);
break;
case SCI_UINT8 :
sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, _piVar, &iRows, &iCols, (unsigned char**)&piData);
printError(&sciErr, 0);
return false;
}
- iRet = writeInterger16Matrix(_iH5File, _pstName, iRows, iCols, (short*)piData);
+ iRet = writeInteger16Matrix(_iH5File, _pstName, iRows, iCols, (short*)piData);
break;
case SCI_UINT16 :
sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, _piVar, &iRows, &iCols, (unsigned short**)&piData);
printError(&sciErr, 0);
return false;
}
- iRet = writeInterger32Matrix(_iH5File, _pstName, iRows, iCols, (int*)piData);
+ iRet = writeInteger32Matrix(_iH5File, _pstName, iRows, iCols, (int*)piData);
break;
case SCI_UINT32 :
sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, _piVar, &iRows, &iCols, (unsigned int**)&piData);
// printError(&sciErr, 0);
// return false;
//}
- //iRet = writeInterger64Matrix(_iH5File, _pstName, iRows, iCols, (long long*)piData);
+ //iRet = writeInteger64Matrix(_iH5File, _pstName, iRows, iCols, (long long*)piData);
//break;
case SCI_UINT64 :
//sciErr = getMatrixOfUnsignedInteger64(_piVar, &iRows, &iCols, (unsigned long long**)&piData);
for (int i = _iStart ; i <= _iEnd ; i++)
{
- int iRows = 0;
- int iCols = 0;
- int iLen = 0;
- int* piAddr = NULL;
- int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int iLen = 0;
+ int* piAddr = NULL;
+ int iType = 0;
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, i, &piAddr);
if (sciErr.iErr)
return 0;
}
- //get filename
- sciErr = getVarType(pvApiCtx, piAddr, &iType);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
-
- if (iType != sci_strings)
+ if(getAllocatedSingleString(pvApiCtx, piAddr, &_pstNameList[iCount]))
{
Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), "export_to_hdf5", i);
return 0;
}
- sciErr = getVarDimension(pvApiCtx, piAddr, &iRows, &iCols);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
-
- if (iRows != 1 || iCols != 1)
- {
- Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), "export_to_hdf5", i);
- Scierror(999, _("%s: Type: %dx%d\n"), "export_to_hdf5", iRows, iCols);
- return 0;
- }
-
- sciErr = getMatrixOfString(pvApiCtx, piAddr, &iRows, &iCols, &iLen, NULL);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
-
- _pstNameList[iCount] = (char*)MALLOC((iLen + 1) * sizeof(char));//+1 for null termination
- sciErr = getMatrixOfString(pvApiCtx, piAddr, &iRows, &iCols, &iLen, &_pstNameList[iCount]);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
-
iCount++;
}
return iCount;
int* piAddr = NULL;
char* pstFilename = NULL;
char* pstExpandedFilename = NULL;
- bool bImport = false;
+ bool bImport = true;
int iSelectedVar = Rhs - 1;
bool bSelectedVar = false;
VarInfo* pInfo = NULL;
bool bRet = true;
-
CheckRhs(1, 1);
CheckLhs(1, 4);
char** pstVarNameList = (char**)MALLOC(sizeof(char*) * iNbItem);
pInfo = (VarInfo*)MALLOC(iNbItem * sizeof(VarInfo));
- if(Lhs != 4)
+ if(Lhs == 1)
{
sciprint("Name Type Size Bytes\n");
sciprint("---------------------------------------------------------------\n");
break;
}
- if(Lhs != 4)
+ if(Lhs == 1)
{
sciprint("%s\n", pInfo[i].pstInfo);
}
}
}
+ else
+ {//no variable returms [] for each Lhs
+ for(int i = 0 ; i < Lhs ; i++)
+ {
+ createEmptyMatrix(pvApiCtx, Rhs + i + 1);
+ LhsVar(i+1) = Rhs + i + 1;
+ }
+
+ PutLhsVar();
+ return 0;
+ }
//1st Lhs
char** pstVarName = (char**)MALLOC(sizeof(char*) * iNbItem);
scichdir(pathdest);
}
+ FREE(pathdest);
/*bug 5629 : to prevent replace directory by file*/
if (isdir(filename))
{
+ FREE(filename);
+ FREE(currentpath);
return -2;
}
scichdir(currentpath);
- if (currentpath)
- {
- FREE(currentpath);
- currentpath = NULL;
- }
- if (filename)
- {
- FREE(filename);
- filename = NULL;
- }
- if (pathdest)
- {
- FREE(pathdest);
- pathdest = NULL;
- }
+ FREE(currentpath);
+ FREE(filename);
return file;
}
/* Used to avoid stack trace to be displayed */
H5E_auto2_t oldfunc;
-
/* TO DO : remove when HDF5 will be fixed ... */
/* HDF5 does not manage no ANSI characters */
/* UGLY workaround :( */
/* Turn off error handling */
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
- file = H5Fopen (filename, H5F_ACC_RDONLY, H5P_DEFAULT);
+ file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT);
/* The following test will display the backtrace in case of error */
/* Deactivated because displayed each time we call 'load' to open a non-HDF5 file */
/*if (file < 0)
if (_iRows != 0 && _iCols != 0)
{
hid_t obj;
- hobj_ref_t *pRef = (hobj_ref_t *) MALLOC(1 * sizeof(hobj_ref_t));
+ hobj_ref_t Ref;
//Read the data.
- status = H5Dread(_iDatasetId, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pRef);
+ status = H5Dread(_iDatasetId, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &Ref);
if (status < 0)
{
return -1;
}
//Open the referenced object, get its name and type.
- obj = H5Rdereference(_iDatasetId, H5R_OBJECT, &pRef[0]);
+ obj = H5Rdereference(_iDatasetId, H5R_OBJECT, &Ref);
readDouble(obj, _iRows, _iCols, _pdblData);
- FREE(pRef);
}
status = H5Dclose(_iDatasetId);
{
hid_t obj;
herr_t status;
- hobj_ref_t *pRef = (hobj_ref_t *) MALLOC(2 * sizeof(hobj_ref_t));
+ hobj_ref_t pRef[2] = {0};
//Read the data.
status = H5Dread(_iDatasetId, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pRef);
status = H5Dread(_iDatasetId, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pData);
if (status < 0)
{
+ FREE(pData);
return -1;
}
if (status < 0)
{
+ FREE(pData);
return -1;
}
}
pstVarName = readAttribute(_iDatasetId, g_SCILAB_CLASS_VARNAME);
strcpy(_pstVarname, pstVarName);
+ FREE(pstVarName);
status = H5Dclose(_iDatasetId);
if (status < 0)
{
+ FREE(pData);
return -1;
}
FREE(pData);
- FREE(pstVarName);
return 0;
}
double *_pdblReal, double *_pdblImg)
{
hid_t obj = 0;
- hobj_ref_t *pRef = (hobj_ref_t *) MALLOC(3 * sizeof(hobj_ref_t));
+ hobj_ref_t pRef[3] = {0};
herr_t status;
/*
return -1;
}
- FREE(pRef);
-
return 0;
}
int readBooleanSparseMatrix(int _iDatasetId, int _iRows, int _iCols, int _iNbItem, int *_piNbItemRow, int *_piColPos)
{
hid_t obj = 0;
- hobj_ref_t *pRef = (hobj_ref_t *) MALLOC(2 * sizeof(hobj_ref_t));
+ hobj_ref_t pRef[2] = {0};
herr_t status;
/*
return -1;
}
- FREE(pRef);
-
return 0;
}
iVarType = sci_undefined;
}
- if (iVarType == 0)
- {
- return 0;
- }
FREE(pstScilabClass);
return iVarType;
}
return pstGroupName;
}
-char *createPathName(char *_pstGroupName, int _iIndex)
+char* createPathName(char *_pstGroupName, int _iIndex)
{
char *pstName = NULL;
char *pstPathName = NULL;
- pstName = (char *)MALLOC(((int)log10((double)(_iIndex + 1)) + 3) * sizeof(char));
+ int iNameLen = (int)log10((double)_iIndex + 1) + 1;
+ iNameLen += 2; //for both '#'
+ iNameLen += 1; //for null termanation
+
+ pstName = (char *)MALLOC(iNameLen * sizeof(char));
//1 for null termination, 2 for '#' characters
sprintf(pstName, "#%d#", _iIndex);
pstPathName = (char *)MALLOC((strlen(_pstGroupName) + strlen(pstName) + 2) * sizeof(char));
//1 for null termination, 1 for separator, 2 for '#' characters
sprintf(pstPathName, "%s/%s", _pstGroupName, pstName);
+ FREE(pstName);
return pstPathName;
}
herr_t status = 0;
hobj_ref_t iRef = 0;
- char *pstPathName = NULL;
-
- //createGroupe and dataset name
- pstPathName = createPathName(_pstGroupName, _iIndex);
-
if (_iRows * _iCols == 0)
{
double dblZero = 0;
}
else
{
+ char *pstPathName = NULL;
+
//Create dataspace. Setting maximum size to NULL sets the maximum
//size to be the current size.
space = H5Screate_simple(1, dims, NULL);
return (hobj_ref_t) (-1);
}
+ //createGroupe and dataset name
+ pstPathName = createPathName(_pstGroupName, _iIndex);
+
//Create the dataset and write the array data to it.
iCompress = enableCompression(9, 1, dims);
dset = H5Dcreate(_iFile, pstPathName, H5T_NATIVE_DOUBLE, space, iCompress);
if (dset < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
status = H5Dwrite(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pdblData);
if (status < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_DOUBLE);
if (status < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
status = addIntAttribute(dset, g_SCILAB_CLASS_ROWS, _iRows);
if (status < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
status = addIntAttribute(dset, g_SCILAB_CLASS_COLS, _iCols);
if (status < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
status = H5Rcreate(&iRef, _iFile, pstPathName, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
+
+ FREE(pstPathName);
}
//Close and release resources.
return (hobj_ref_t) (-1);
}
- FREE(pstPathName);
-
return iRef;
}
if (status < 0)
{
+ FREE(pstGroupName);
return -1;
}
pRef[0] = writeCommomDoubleMatrix(_iFile, pstGroupName, _pstDatasetName, 0, _iRows, _iCols, _pdblReal);
pRef[1] = writeCommomDoubleMatrix(_iFile, pstGroupName, _pstDatasetName, 1, _iRows, _iCols, _pdblImg);
+ FREE(pstGroupName);
if (pRef[0] == 0 || pRef[1] == 0)
{
return 1;
return -1;
}
- FREE(pstGroupName);
return 0;
}
hid_t iCompress = 0;
hobj_ref_t *pData = 0;
- char *pstName = NULL;
char *pstPathName = NULL;
-
char *pstGroupName = NULL;
// Create ref matrix
- pData = (hobj_ref_t *) MALLOC(_iRows * _iCols * sizeof(hobj_ref_t));
+ pData = (hobj_ref_t *)MALLOC(dims[0] * sizeof(hobj_ref_t));
// Generate groupname #<dataSetName>#
pstGroupName = createGroupName(_pstDatasetName);
status = H5Gclose(group);
//Now create each String as a dedicated DataSet.
- for (i = 0; i < _iRows * _iCols; i++)
+ for (i = 0 ; i < dims[0] ; i++)
{
pstPathName = createPathName(pstGroupName, i);
if (status < 0)
{
+ FREE(pstPathName);
+ FREE(pstGroupName);
+ FREE(pData);
return -1;
}
+
// create the ref
status = H5Rcreate(&pData[i], _iFile, pstPathName, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstPathName);
+ FREE(pstGroupName);
+ FREE(pData);
return -1;
}
- FREE(pstName);
FREE(pstPathName);
}
+ FREE(pstGroupName);
//Create dataspace. Setting maximum size to NULL sets the maximum size to be the current size.
space = H5Screate_simple(1, dims, NULL);
if (status < 0)
{
+ FREE(pData);
return -1;
}
dset = H5Dcreate(_iFile, _pstDatasetName, H5T_STD_REF_OBJ, space, iCompress);
if (dset < 0)
{
+ FREE(pData);
return -1;
}
status = H5Dwrite(dset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pData);
if (status < 0)
{
+ FREE(pData);
return -1;
}
+
+ FREE(pData);
//Add attribute SCILAB_Class = poly to dataset
status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_POLY);
if (status < 0)
return -1;
}
- FREE(pstGroupName);
- FREE(pData);
-
return 0;
}
return writeCommonPolyMatrix(_iFile, _pstDatasetName, _pstVarName, 1, _iRows, _iCols, _piNbCoef, _pdblReal, _pdblImg);
}
-int writeInterger8Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, char *_pcData)
+int writeInteger8Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, char *_pcData)
{
hsize_t piDims[1] = { _iRows * _iCols };
herr_t status = 0;
return 0;
}
-int writeInterger16Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, short *_psData)
+int writeInteger16Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, short *_psData)
{
hsize_t piDims[1] = { _iRows * _iCols };
herr_t status = 0;
return 0;
}
-int writeInterger32Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, int *_piData)
+int writeInteger32Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, int *_piData)
{
hsize_t piDims[1] = { _iRows * _iCols };
herr_t status = 0;
return 0;
}
-int writeInterger64Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, long long *_pllData)
+int writeInteger64Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, long long *_pllData)
{
hsize_t piDims[1] = { _iRows * _iCols };
herr_t status = 0;
hid_t dset = 0;
hid_t group = 0;
hid_t iCompress = 0;
- hobj_ref_t *pDataRef = 0;
+ hobj_ref_t pDataRef[3] = {0};
char *pstRowPath = NULL;
char *pstColPath = NULL;
char *pstDataPath = NULL;
char *pstGroupName = NULL;
- // Create ref matrix
- //3 refs : 1 for data, 1 for Number Item by row ( row size ) and 1 for column position
- pDataRef = (hobj_ref_t *) MALLOC(3 * sizeof(hobj_ref_t));
-
// Generate groupname #<dataSetName>#
pstGroupName = createGroupName(_pstDatasetName);
status = H5Gclose(group);
if (status < 0)
{
+ FREE(pstGroupName);
return -1;
}
//Create each sub dataset and insert data
pstRowPath = createPathName(pstGroupName, 0);
- status = writeInterger32Matrix(_iFile, pstRowPath, 1, _iRows, _piNbItemRow);
+ status = writeInteger32Matrix(_iFile, pstRowPath, 1, _iRows, _piNbItemRow);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstGroupName);
return -1;
}
status = H5Rcreate(&pDataRef[0], _iFile, pstRowPath, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstGroupName);
return -1;
}
pstColPath = createPathName(pstGroupName, 1);
- status = writeInterger32Matrix(_iFile, pstColPath, 1, _iNbItem, _piColPos);
+ status = writeInteger32Matrix(_iFile, pstColPath, 1, _iNbItem, _piColPos);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstGroupName);
return -1;
}
status = H5Rcreate(&pDataRef[1], _iFile, pstColPath, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstGroupName);
return -1;
}
{
status = writeDoubleMatrix(_iFile, pstDataPath, 1, _iNbItem, _pdblReal);
}
+
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstDataPath);
+ FREE(pstGroupName);
return -1;
}
status = H5Rcreate(&pDataRef[2], _iFile, pstDataPath, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstDataPath);
+ FREE(pstGroupName);
return -1;
}
FREE(pstRowPath);
FREE(pstColPath);
FREE(pstDataPath);
+ FREE(pstGroupName);
//Create dataspace. Setting maximum size to NULL sets the maximum size to be the current size.
space = H5Screate_simple(1, dims, NULL);
return -1;
}
- FREE(pstGroupName);
-
return 0;
}
hid_t dset = 0;
hid_t group = 0;
hid_t iCompress = 0;
- hobj_ref_t *pDataRef = 0;
+ hobj_ref_t pDataRef[2] = {0};
char *pstRowPath = NULL;
char *pstColPath = NULL;
char *pstGroupName = NULL;
- // Create ref matrix
- //2 refs : 1 for data, 1 for Number Item by row ( row size ) and 1 for column position
- pDataRef = (hobj_ref_t *) MALLOC(2 * sizeof(hobj_ref_t));
-
// Generate groupname #<dataSetName>#
pstGroupName = createGroupName(_pstDatasetName);
status = H5Gclose(group);
if (status < 0)
{
+ FREE(pstGroupName);
return -1;
}
//Create each sub dataset and insert data
pstRowPath = createPathName(pstGroupName, 0);
- status = writeInterger32Matrix(_iFile, pstRowPath, 1, _iRows, _piNbItemRow);
+ status = writeInteger32Matrix(_iFile, pstRowPath, 1, _iRows, _piNbItemRow);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstGroupName);
return -1;
}
status = H5Rcreate(&pDataRef[0], _iFile, pstRowPath, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstGroupName);
return -1;
}
pstColPath = createPathName(pstGroupName, 1);
- status = writeInterger32Matrix(_iFile, pstColPath, 1, _iNbItem, _piColPos);
+ status = writeInteger32Matrix(_iFile, pstColPath, 1, _iNbItem, _piColPos);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstGroupName);
return -1;
}
status = H5Rcreate(&pDataRef[1], _iFile, pstColPath, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstGroupName);
return -1;
}
//FREE group names
FREE(pstRowPath);
FREE(pstColPath);
+ FREE(pstGroupName);
//Create dataspace. Setting maximum size to NULL sets the maximum size to be the current size.
space = H5Screate_simple(1, dims, NULL);
return -1;
}
- FREE(pstGroupName);
- FREE(pDataRef);
-
return 0;
}
loadFunction = %_load;
end
- variableList = listvarinfile(filename);
+ //multiple output variables to prevent listinfile prints
+ [variableList, __varB__, __varC__, __varD__] = listvarinfile(filename);
//
if size(varargin) <> 0 then