]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Issue 0020613: EDF 1106 : Modify Node Marker in SMESH and VISU
authorouv <ouv@opencascade.com>
Thu, 25 Mar 2010 13:34:14 +0000 (13:34 +0000)
committerouv <ouv@opencascade.com>
Thu, 25 Mar 2010 13:34:14 +0000 (13:34 +0000)
src/HDFPersist/HDFascii.cc
src/HDFPersist/HDFascii.hxx

index 33750e60959ba02b6142845c1de87125a5977439..e1894af6fe1109879cdd3597afcabfcc0b18da67 100644 (file)
@@ -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()) ;
index e51edfb309d68ea26adf25358c70f00265c4f6a3..67b72360bcd6e38383beda91442b8c27954901e9 100644 (file)
@@ -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);
 };