From: ouv Date: Thu, 25 Mar 2010 13:34:14 +0000 (+0000) Subject: Issue 0020613: EDF 1106 : Modify Node Marker in SMESH and VISU X-Git-Tag: V5_1_4a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2dd44a3a7b2a1bde14b68eb5091b9a092e150ae9;p=modules%2Fkernel.git Issue 0020613: EDF 1106 : Modify Node Marker in SMESH and VISU --- diff --git a/src/HDFPersist/HDFascii.cc b/src/HDFPersist/HDFascii.cc index 33750e609..e1894af6f 100644 --- a/src/HDFPersist/HDFascii.cc +++ b/src/HDFPersist/HDFascii.cc @@ -372,19 +372,27 @@ void SaveAttributeInASCIIfile(HDFattribute *hdf_attribute, FILE* fp, int ident) // Returns a name of directory where a created HDF file is placed // The created file is named "hdf_from_ascii.hdf" //============================================================================ -char* HDFascii::ConvertFromASCIIToHDF(const char* thePath) +char* HDFascii::ConvertFromASCIIToHDF(const char* thePath, + bool isReplace) { - // Get a temporary directory to store a file - string aTmpDir = GetTmpDir(), aFileName("hdf_from_ascii.hdf"); - // Build a full file name of temporary file - string aFullName = aTmpDir + aFileName; + string aTmpDir, aFullName; + if(!isReplace) { + // Get a temporary directory to store a file + aTmpDir = GetTmpDir(); + // Build a full file name of temporary file + aFullName = aTmpDir + "hdf_from_ascii.hdf"; + } + else { + aTmpDir = thePath; + aFullName = string(thePath)+".ascii_tmp"; + } - HDFfile *hdf_file = new HDFfile((char*)aFullName.c_str()); - hdf_file->CreateOnDisk(); - FILE *fp = fopen(thePath, "r"); if(!fp) return NULL; + HDFfile *hdf_file = new HDFfile((char*)aFullName.c_str()); + hdf_file->CreateOnDisk(); + char type[9]; int nbsons, i; fscanf(fp, "%s", type); @@ -428,6 +436,13 @@ char* HDFascii::ConvertFromASCIIToHDF(const char* thePath) hdf_file->CloseOnDisk(); delete hdf_file; + if(isReplace) { + if(Exists(aFullName)) + Move(aFullName, thePath); + else + return NULL; + } + int length = strlen(aTmpDir.c_str()); char *new_str = new char[ 1+length ]; strcpy(new_str , aTmpDir.c_str()) ; diff --git a/src/HDFPersist/HDFascii.hxx b/src/HDFPersist/HDFascii.hxx index e51edfb30..67b72360b 100644 --- a/src/HDFPersist/HDFascii.hxx +++ b/src/HDFPersist/HDFascii.hxx @@ -39,7 +39,8 @@ public: bool isReplaced = true, const char* theExtension = NULL); - static char* ConvertFromASCIIToHDF(const char* thePath); + static char* ConvertFromASCIIToHDF(const char* thePath, + bool isReplaced = false); static bool isASCII(const char* thePath); };