From 3862bb1bee071779e3646bab0fb4f0626e93fca0 Mon Sep 17 00:00:00 2001 From: Antoine ELIAS Date: Thu, 9 Aug 2012 09:20:28 +0200 Subject: [PATCH] check version to import SOD file Change-Id: Idbc8cef353de2e90c51333097630dec8ecf5adf4 --- .../hdf5/sci_gateway/cpp/sci_export_to_hdf5.cpp | 6 +++--- .../hdf5/sci_gateway/cpp/sci_import_from_hdf5.cpp | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_export_to_hdf5.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_export_to_hdf5.cpp index 9e11c2e..32b8c83 100644 --- a/scilab/modules/hdf5/sci_gateway/cpp/sci_export_to_hdf5.cpp +++ b/scilab/modules/hdf5/sci_gateway/cpp/sci_export_to_hdf5.cpp @@ -144,9 +144,9 @@ int sci_export_to_hdf5(char *fname, unsigned long fname_len) if (bAppendMode) { int iVersion = getSODFormatAttribute(iH5File); - if (iVersion != -1 && iVersion > SOD_FILE_VERSION) - { - Scierror(999, _("%s: Wrong SOD file format version. Expected: %d from file: %d\n"), fname, SOD_FILE_VERSION, iVersion); + if (iVersion != -1 && iVersion != SOD_FILE_VERSION) + {//to update version must be the same + Scierror(999, _("%s: Wrong SOD file format version. Expected: %d Found: %d\n"), fname, SOD_FILE_VERSION, iVersion); return 1; } diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_import_from_hdf5.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_import_from_hdf5.cpp index 121a967..10d7752 100644 --- a/scilab/modules/hdf5/sci_gateway/cpp/sci_import_from_hdf5.cpp +++ b/scilab/modules/hdf5/sci_gateway/cpp/sci_import_from_hdf5.cpp @@ -23,6 +23,7 @@ extern "C" #include "../../../call_scilab/includes/call_scilab.h" #include "h5_fileManagement.h" #include "h5_readDataFromFile.h" +#include "h5_attributeConstants.h" #include "intmacr2tree.h" #include "expandPathVariable.h" } @@ -96,6 +97,14 @@ int sci_import_from_hdf5(char *fname, unsigned long fname_len) FREE(pstExpandedFilename); FREE(pstFilename); + //manage version information + int iVersion = getSODFormatAttribute(iFile); + if (iVersion > SOD_FILE_VERSION) + {//can't read file with version newer that me ! + Scierror(999, _("%s: Wrong SOD file format version. Max Expected: %d Found: %d\n"), fname, SOD_FILE_VERSION, iVersion); + return 1; + } + if (iSelectedVar) { //selected variable -- 1.7.9.5