1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDS_Tool.cxx
21 // Created : Mon Oct 21 16:24:34 2002
22 // Author : Sergey RUIN
29 #include <OSD_Path.hxx>
30 #include <OSD_File.hxx>
31 #include <OSD_Protection.hxx>
32 #include <OSD_Directory.hxx>
33 #include <TCollection_AsciiString.hxx>
47 bool CreateAttributeFromASCII(HDFinternalObject *father, FILE* fp);
48 bool CreateDatasetFromASCII(HDFcontainerObject *father, FILE *fp);
49 bool CreateGroupFromASCII(HDFcontainerObject *father, FILE *fp);
51 void SaveAttributeInASCIIfile(HDFattribute *hdf_attribute, FILE* fp, int ident);
52 void SaveGroupInASCIIfile(HDFgroup *hdf_group, FILE* fp, int ident);
53 void SaveDatasetInASCIIfile(HDFdataset *hdf_dataset, FILE* fp, int ident);
56 char* makeName(char* name);
57 char* restoreName(char* name);
58 void write_float64(FILE* fp, hdf_float64* value);
59 void read_float64(FILE* fp, hdf_float64* value);
61 #define MAX_STRING_SIZE 65535
62 #define MAX_ID_SIZE 20
63 #define NB_FLOAT_IN_ROW 3
64 #define NB_INTEGER_IN_ROW 9
66 #define ASCIIHDF_ID "ASCIIHDF"
67 #define ATTRIBUTE_ID "ATTRIBUTE"
68 #define DATASET_ID "DATASET"
69 #define GROUP_ID "GROUP"
71 #define ASCIIHDF_ID_END "ASCIIHDF_END"
72 #define ATTRIBUTE_ID_END "ATTRIBUTE_END"
73 #define DATASET_ID_END "DATASET_END"
74 #define GROUP_ID_END "GROUP_END"
77 //============================================================================
79 // purpose : Returns True if the file is a converted to ASCII HDF file
80 //============================================================================
81 bool HDFascii::isASCII(const char* thePath) {
83 if(!(fd = open(thePath, O_RDONLY))) return false;
84 char* aBuffer = new char[9];
89 if(strcmp(aBuffer, ASCIIHDF_ID) == 0) return true;
94 //############################## HDF => ASCII ################################
96 //============================================================================
97 // function : ConvertFromHDFToASCII
98 // purpose : Converts a file pointed by thePath to ASCII format
99 // If isReplace is true the newly created file will replace the existent one.
100 // If isReplace is false theExtension will be added to a created file name
101 // Returns the file name of ASCII file
102 //============================================================================
103 char* HDFascii::ConvertFromHDFToASCII(const char* thePath,
105 const char* theExtension)
107 TCollection_AsciiString aPath((char*)thePath);
109 if(theExtension == NULL) aPath += ".asc";
110 else aPath += (char*)theExtension;
113 TCollection_AsciiString aFileName(aPath);
114 if(isReplace) aFileName=aPath+".ascii_tmp";
116 HDFfile *hdf_file = new HDFfile((char*)thePath);
117 hdf_file->OpenOnDisk(HDF_RDONLY);
119 char name[HDF_NAME_MAX_LEN+1];
120 int nbsons = hdf_file->nInternalObjects(), nbAttr = hdf_file->nAttributes();
122 FILE* fp = fopen(aFileName.ToCString(), "w");
123 fprintf(fp, "%s\n", ASCIIHDF_ID);
124 fprintf(fp, "%i\n", nbsons+nbAttr);
126 for(unsigned j=0; j<nbAttr; j++) {
127 char* attr_name = hdf_file->GetAttributeName(j);
128 HDFattribute *hdf_attribute = new HDFattribute(attr_name, hdf_file);
130 SaveAttributeInASCIIfile(hdf_attribute, fp, 0);
134 for (Standard_Integer i=0; i<nbsons; i++) {
135 hdf_file->InternalObjectIndentify(i,name);
136 if (strncmp(name, "INTERNAL_COMPLEX",16) == 0) continue;
138 hdf_object_type type = hdf_file->InternalObjectType(name);
140 if(type == HDF_DATASET) {
141 HDFdataset* hdf_dataset = new HDFdataset(name, hdf_file);
142 SaveDatasetInASCIIfile(hdf_dataset, fp, 0);
144 } else if(type == HDF_GROUP) {
145 HDFgroup *hdf_group = new HDFgroup(name, hdf_file);
146 SaveGroupInASCIIfile(hdf_group, fp, 0);
151 fprintf(fp, "%s", ASCIIHDF_ID_END);
155 hdf_file->CloseOnDisk();
159 OSD_Path anOSDPath(aFileName);
160 OSD_File anOSDFile(anOSDPath);
161 if(anOSDFile.Exists())
162 anOSDFile.Move(aPath);
167 int length = strlen(aPath.ToCString());
168 char *new_str = new char[ 1+length ];
169 strcpy(new_str , aPath.ToCString()) ;
175 //============================================================================
176 // function : SaveGroupInASCIIfile
178 //============================================================================
179 void SaveGroupInASCIIfile(HDFgroup *hdf_group, FILE* fp, int ident)
181 hdf_group->OpenOnDisk();
183 TCollection_AsciiString anIdent(ident, '\t');
184 int nbsons = hdf_group->nInternalObjects(), nbAttr = hdf_group->nAttributes();
186 /*fprintf(fp, "%s%s\n", anIdent.ToCString(), GROUP_ID);*/
187 fprintf(fp, "%s\n", GROUP_ID);
189 char* name = makeName(hdf_group->GetName());
191 /*fprintf(fp, "%s%s %i\n", anIdent.ToCString(), name, nbsons+nbAttr);*/
192 fprintf(fp, "%s %i\n", name, nbsons+nbAttr);
195 for(unsigned j=0; j<nbAttr; j++) {
196 name = hdf_group->GetAttributeName(j);
197 HDFattribute *hdf_attribute = new HDFattribute(name, hdf_group);
199 SaveAttributeInASCIIfile(hdf_attribute, fp, ident+1);
203 char objName[HDF_NAME_MAX_LEN+1];
205 for (int i=0; i<nbsons; i++) {
206 hdf_group->InternalObjectIndentify(i, objName);
208 if (strncmp(objName, "INTERNAL_COMPLEX",16) == 0) continue;
210 hdf_object_type type = hdf_group->InternalObjectType(objName);
212 if (type == HDF_DATASET) {
213 HDFdataset* hdf_dataset = new HDFdataset(objName, hdf_group);
214 SaveDatasetInASCIIfile(hdf_dataset, fp, ident+1);
216 } else if (type == HDF_GROUP) {
217 HDFgroup *hdf_subgroup = new HDFgroup(objName, hdf_group);
218 SaveGroupInASCIIfile(hdf_subgroup, fp, ident+1);
223 /*fprintf(fp, "%s%s\n", anIdent.ToCString(), GROUP_ID_END);*/
224 fprintf(fp, "%s\n", GROUP_ID_END);
226 hdf_group->CloseOnDisk();
229 //============================================================================
230 // function : SaveDatasetInASCIIfile
232 //============================================================================
233 void SaveDatasetInASCIIfile(HDFdataset *hdf_dataset, FILE* fp, int ident)
235 hdf_dataset->OpenOnDisk();
237 long size = hdf_dataset->GetSize();
238 long ndim = hdf_dataset->nDim(); //Get number of dimesions
239 hdf_size *dim = new hdf_size[ndim];
240 hdf_type type = hdf_dataset->GetType();
241 hdf_byte_order order = hdf_dataset->GetOrder();
242 int nbAttr = hdf_dataset->nAttributes();
244 TCollection_AsciiString anIdent(ident, '\t');
245 TCollection_AsciiString anIdentChild(ident+1, '\t');
247 char* name = makeName(hdf_dataset->GetName());
249 /*fprintf(fp, "%s%s\n", anIdent.ToCString(), DATASET_ID);*/
250 fprintf(fp, "%s\n", DATASET_ID);
251 /*fprintf(fp, "%s%s %i %i\n", anIdent.ToCString(), name, type, nbAttr);*/
252 fprintf(fp, "%s %i %i\n", name, type, nbAttr);
255 hdf_dataset->GetDim(dim);
256 /*fprintf(fp, "%s %i\n", anIdentChild.ToCString(), ndim);*/
257 fprintf(fp, " %i\n", ndim);
259 for(int i = 0;i < ndim;i++) {
260 /*fprintf(fp, "%s%i", anIdentChild.ToCString(), dim[i]);*/
261 fprintf(fp, " %i", dim[i]);
264 /*fprintf(fp, "%s\n", anIdentChild.ToCString());*/
268 /*fprintf(fp, "%s%li:", anIdentChild.ToCString(), size);*/
269 // fprintf(fp, "%li:", size);
270 fprintf(fp, "%li %i:", size, order);
272 if (type == HDF_STRING) {
273 char* val = new char[size];
274 hdf_dataset->ReadFromDisk(val);
275 fwrite(val, 1, size, fp);
277 } else if (type == HDF_FLOAT64) {
278 hdf_float64* val = new hdf_float64[size];
279 hdf_dataset->ReadFromDisk(val);
281 for (int i = 0, j = 0; i < size; i++) {
282 write_float64(fp, &val[i]);
283 if(++j == NB_FLOAT_IN_ROW) {
287 else fprintf(fp," ");
290 } else if(type == HDF_INT64) {
291 hdf_int64* val = new hdf_int64[size];
292 hdf_dataset->ReadFromDisk(val);
294 for (int i = 0, j = 0; i < size; i++) {
295 fprintf(fp, " %li", val[i]);
296 if(++j == NB_INTEGER_IN_ROW) {
302 } else if(type == HDF_INT32) {
303 hdf_int32* val = new hdf_int32[size];
304 hdf_dataset->ReadFromDisk(val);
306 for (int i = 0, j = 0; i < size; i++) {
307 fprintf(fp, " %i", val[i]);
308 if(++j == NB_INTEGER_IN_ROW) {
319 for(unsigned j=0; j<nbAttr; j++) {
321 for(j=0; j<nbAttr; j++) {
323 name = hdf_dataset->GetAttributeName(j);
324 HDFattribute *hdf_attribute = new HDFattribute(name, hdf_dataset);
326 SaveAttributeInASCIIfile(hdf_attribute, fp, ident+1);
330 /*fprintf(fp, "%s%s\n", anIdent.ToCString(), DATASET_ID_END); */
331 fprintf(fp, "%s\n", DATASET_ID_END);
333 hdf_dataset->CloseOnDisk();
337 //============================================================================
338 // function : SaveAttributeInASCIIfile
340 //============================================================================
341 void SaveAttributeInASCIIfile(HDFattribute *hdf_attribute, FILE* fp, int ident)
343 hdf_attribute->OpenOnDisk();
345 hdf_type type = hdf_attribute->GetType();
347 TCollection_AsciiString anIdent(ident, '\t');
348 TCollection_AsciiString anIdentChild(ident+1, '\t');
350 char* name = makeName(hdf_attribute->GetName());
351 int size = hdf_attribute->GetSize();
353 /*fprintf(fp, "%s%s\n", anIdent.ToCString(), ATTRIBUTE_ID);*/
354 fprintf(fp, "%s\n", ATTRIBUTE_ID);
355 /*fprintf(fp, "%s%s %i %i\n", anIdent.ToCString(), name, type, size);*/
356 fprintf(fp, "%s %i %i\n", name, type, size);
360 if (type == HDF_STRING) {
361 char* val = new char[size+1];
362 hdf_attribute->ReadFromDisk(val);
363 /*fprintf(fp, "%s:", anIdentChild.ToCString());*/
365 fwrite(val, 1, size, fp);
368 } else if (type == HDF_FLOAT64) {
370 hdf_attribute->ReadFromDisk(&val);
371 /*fprintf(fp, "%s", anIdentChild.ToCString());*/
372 write_float64(fp, &val);
374 } else if(type == HDF_INT64) {
376 hdf_attribute->ReadFromDisk(&val);
377 /*fprintf(fp, "%s%li \n", anIdentChild.ToCString(), val);*/
378 fprintf(fp, "%li \n", val);
379 } else if(type == HDF_INT32) {
381 hdf_attribute->ReadFromDisk(&val);
382 /*fprintf(fp, "%s%i \n", anIdentChild.ToCString(), val);*/
383 fprintf(fp, "%i \n", val);
386 /*fprintf(fp, "%s%s\n", anIdent.ToCString(), ATTRIBUTE_ID_END);*/
387 fprintf(fp, "%s\n", ATTRIBUTE_ID_END);
389 hdf_attribute->CloseOnDisk();
392 //############################## ASCII => HDF ################################
394 //============================================================================
395 // function : ConvertFromASCIIToHDF
396 // purpose : Converts a file pointed by thePath to HDF format
397 // Returns a name of directory where a created HDF file is placed
398 // The created file is named "hdf_from_ascii.hdf"
399 //============================================================================
400 char* HDFascii::ConvertFromASCIIToHDF(const char* thePath)
402 // Get a temporary directory to store a file
403 TCollection_AsciiString aTmpDir = GetTmpDir(), aFileName("hdf_from_ascii.hdf");
404 // Build a full file name of temporary file
405 TCollection_AsciiString aFullName = aTmpDir + aFileName;
407 HDFfile *hdf_file = new HDFfile(aFullName.ToCString());
408 hdf_file->CreateOnDisk();
410 FILE *fp = fopen(thePath, "r");
415 fscanf(fp, "%s", type);
416 fscanf(fp, "%i",&nbsons);
418 if(strcmp(type, ASCIIHDF_ID) != 0) return NULL;
420 for(i = 0; i < nbsons; i++) {
421 char id_of_begin[MAX_ID_SIZE];
422 fscanf(fp, "%s\n", id_of_begin);
424 if(strcmp(id_of_begin, GROUP_ID) == 0) {
425 if(!CreateGroupFromASCII(hdf_file, fp)) {
426 cout << "ConvertFromASCIIToHDF : Can not create group number " << i << endl;
430 else if(strcmp(id_of_begin, DATASET_ID) == 0) {
431 if(!CreateDatasetFromASCII(hdf_file, fp)) {
432 cout << "ConvertFromASCIIToHDF :Can not create dataset number " << i << endl;
436 else if(strcmp(id_of_begin, ATTRIBUTE_ID) == 0) {
437 if(!CreateAttributeFromASCII(hdf_file, fp)) {
438 cout << "ConvertFromASCIIToHDF :Can not create attribute number " << i << endl;
443 cout << "ConvertFromASCIIToHDF : Unrecognized type " << id_of_begin << endl;
446 char id_of_end[MAX_ID_SIZE];
447 fscanf(fp, "%s", id_of_end);
448 if(strcmp(id_of_end, ASCIIHDF_ID_END) != 0) {
449 cout << "ConvertFromASCIIToHDF : Can not find the end ASCII token " << endl;
453 hdf_file->CloseOnDisk();
456 int length = strlen(aTmpDir.ToCString());
457 char *new_str = new char[ 1+length ];
458 strcpy(new_str , aTmpDir.ToCString()) ;
464 //============================================================================
465 // function : CreateGroupFromASCII
466 // purpose : Creates a HDF group from a set attributes situated under theLabel
467 //============================================================================
468 bool CreateGroupFromASCII(HDFcontainerObject *father, FILE *fp)
470 char name[HDF_NAME_MAX_LEN+1];
472 fscanf(fp, "%s %i\n", name, &nbsons);
474 char* new_name = restoreName(name);
476 HDFgroup* hdf_group = new HDFgroup(new_name, father);
480 hdf_group->CreateOnDisk();
482 for(i = 0; i < nbsons; i++) {
483 char id_of_begin[MAX_ID_SIZE];
484 fscanf(fp, "%s\n", id_of_begin);
486 if(strcmp(id_of_begin, GROUP_ID) == 0) {
487 if(!CreateGroupFromASCII(hdf_group, fp)) {
488 cout << "Can not create subgroup " << i << " for group " << name << endl;
492 else if(strcmp(id_of_begin, DATASET_ID) == 0) {
493 if(!CreateDatasetFromASCII(hdf_group, fp)) {
494 cout << "Can not create dataset " << i << " for group " << name << endl;
498 else if(strcmp(id_of_begin, ATTRIBUTE_ID) == 0) {
499 if(!CreateAttributeFromASCII(hdf_group, fp)) {
500 cout << "Can not create attribute " << i << " for group " << name << endl;
505 cout << "CreateGroupFromASCII : Unrecognized type " << id_of_begin << endl;
508 hdf_group->CloseOnDisk();
509 hdf_group = 0; //will be deleted by father destructor
511 char id_of_end[MAX_ID_SIZE];
512 fscanf(fp, "%s\n", id_of_end);
513 if(strcmp(id_of_end, GROUP_ID_END) != 0) {
514 cout << "CreateGroupFromASCII : Invalid end token : " << id_of_end << endl;
522 //============================================================================
523 // function : CreateDatasetFromASCII
524 // purpose : Creates a HDF dataset from a set attributes situated under theLabel
525 //============================================================================
526 bool CreateDatasetFromASCII(HDFcontainerObject *father, FILE *fp)
528 char name[HDF_NAME_MAX_LEN+1];
530 hdf_byte_order order;
534 fscanf(fp, "%s %i %i\n", name, &type, &nbAttr);
535 char* new_name = restoreName(name);
537 fscanf(fp, "%i\n", &nbDim);
539 hdf_size* sizeArray = new hdf_size[nbDim];
541 for(i = 0; i<nbDim; i++) {
542 fscanf(fp, "%i\n", &dim);
546 // order (2-d member) was not written in earlier versions
548 int nbRead = fscanf(fp, "%li %i%c", &size, &order, &tmp);
549 if ( nbRead < 2 ) { // fscanf stops before ":"
550 fscanf(fp, "%c", &tmp);
551 order = H5T_ORDER_NONE;
553 if ( type != HDF_FLOAT64 ) // use order only for FLOAT64
554 order = H5T_ORDER_NONE;
556 HDFdataset* hdf_dataset = new HDFdataset(new_name, father,type, sizeArray, nbDim, order);
560 hdf_dataset->CreateOnDisk();
562 if (type == HDF_STRING) {
563 char *val = new char[size+1];
564 fread(val, 1, size, fp);
565 hdf_dataset->WriteOnDisk(val);
567 } else if (type == HDF_FLOAT64) {
568 hdf_float64* val = new hdf_float64[size];
569 for(i=0; i<size; i++) {
570 read_float64(fp, &(val[i]));
572 hdf_dataset->WriteOnDisk(val);
574 } else if(type == HDF_INT64) {
575 hdf_int64* val = new hdf_int64[size];
576 for(i=0; i<size; i++) {
577 fscanf(fp, " %li", &(val[i]));
579 hdf_dataset->WriteOnDisk(val);
581 } else if(type == HDF_INT32) {
582 hdf_int32* val = new hdf_int32[size];
583 for(i=0; i<size; i++) {
584 fscanf(fp, " %i", &(val[i]));
586 hdf_dataset->WriteOnDisk(val);
590 char token[MAX_ID_SIZE];
592 for(i = 0; i < nbAttr; i++) {
593 fscanf(fp, "%s\n", token);
595 if(strcmp(token, ATTRIBUTE_ID) == 0) {
596 if(!CreateAttributeFromASCII(hdf_dataset, fp)) {
597 cout << "Can not create attribute " << i << " for dataset " << name << endl;
602 cout << "CreateGroupFromASCII : Unrecognized type " << token << endl;
607 fscanf(fp, "%s\n", token);
608 if(strcmp(token, DATASET_ID_END) != 0) {
609 cout << "CreateDatasetFromASCII : Invalid end token : " << token << endl;
613 hdf_dataset->CloseOnDisk();
614 hdf_dataset = 0; //will be deleted by father destructor
620 //============================================================================
621 // function : CreateAttributeFromASCII
622 // purpose : Creates a HDF attribute from a set attributes situated under theLabel
623 //============================================================================
624 bool CreateAttributeFromASCII(HDFinternalObject *father, FILE* fp)
626 char name[HDF_NAME_MAX_LEN+1];
630 fscanf(fp, "%s %i %i\n", name, &type, &size);
631 char* new_name = restoreName(name);
632 HDFattribute* hdf_attribute = new HDFattribute(new_name, father, type, size);
634 hdf_attribute->CreateOnDisk();
638 if (type == HDF_STRING) {
640 fscanf(fp, "%c", &tmp);
641 char *val = new char[size+1];
643 fread(val, 1, size, fp);
644 hdf_attribute->WriteOnDisk(val);
646 } else if (type == HDF_FLOAT64) {
648 read_float64(fp, &val);
649 hdf_attribute->WriteOnDisk(&val);
650 } else if(type == HDF_INT64) {
652 fscanf(fp, "%li", &val);
653 hdf_attribute->WriteOnDisk(&val);
654 } else if(type == HDF_INT32) {
656 fscanf(fp, "%i", &val);
657 hdf_attribute->WriteOnDisk(&val);
660 hdf_attribute->CloseOnDisk();
661 hdf_attribute = 0; //will be deleted by father destructor
664 char id_of_end[MAX_ID_SIZE];
665 fscanf(fp, "%s\n", id_of_end);
666 if(strcmp(id_of_end, ATTRIBUTE_ID_END) != 0) {
667 cout << "CreateAttributeFromASCII : Invalid end token : " << id_of_end << endl;
675 //============================================================================
676 // function : GetTempDir
677 // purpose : Return a temp directory to store created files like "/tmp/sub_dir/"
678 //============================================================================
681 //Find a temporary directory to store a file
683 TCollection_AsciiString aTmpDir;
687 aTmp = getenv("TMP");
689 aTmpDir = TCollection_AsciiString(aTmp);
691 aTmpDir = TCollection_AsciiString("C:\\");
693 aTmpDir = TCollection_AsciiString("/tmp/");
696 srand((unsigned int)time(NULL));
698 int aRND = 999 + (int)(100000.0*rand()/(RAND_MAX+1.0)); //Get a random number to present a name of a sub directory
699 TCollection_AsciiString aSubDir(aRND);
700 if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876");
702 aTmpDir += aSubDir; //Get RND sub directory
705 if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
707 if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
710 OSD_Path aPath(aTmpDir);
711 OSD_Directory aDir(aPath);
713 for(aRND = 0; aDir.Exists(); aRND++) {
714 aTmpDir.Insert((aTmpDir.Length() - 1), TCollection_AsciiString(aRND)); //Build a unique directory name
715 aPath = OSD_Path(aTmpDir);
716 aDir = OSD_Directory(aPath);
719 OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX);
720 aDir.Build(aProtection);
722 int length = strlen(aTmpDir.ToCString());
723 char *new_str = new char[ 1+length ];
724 strcpy(new_str , aTmpDir.ToCString());
729 char* makeName(char* name)
731 TCollection_AsciiString aName(name), aNewName;
732 Standard_Integer i, length = aName.Length();
733 char replace = (char)19;
735 for(i=1; i<=length; i++) {
736 if(aName.Value(i) == ' ') aNewName+=replace;
737 else aNewName += aName.Value(i);
740 length = strlen(aNewName.ToCString());
741 char *new_str = new char[ 1+length ];
742 strcpy(new_str , aNewName.ToCString()) ;
746 char* restoreName(char* name)
748 TCollection_AsciiString aName(name), aNewName;
749 Standard_Integer i, length = aName.Length();
750 char replace = (char)19;
752 for(i=1; i<=length; i++) {
753 if(aName.Value(i) == replace) aNewName+=' ';
754 else aNewName += aName.Value(i);
757 length = strlen(aNewName.ToCString());
758 char *new_str = new char[ 1+length ];
759 strcpy(new_str , aNewName.ToCString()) ;
763 void write_float64(FILE* fp, hdf_float64* value)
765 unsigned char* array = (unsigned char*)value;
766 for(int i = 0; i < sizeof(hdf_float64); i++) {
767 unsigned tmp = (unsigned short)array[i];
768 fprintf(fp, " %2x", tmp);
772 void read_float64(FILE* fp, hdf_float64* value)
774 unsigned char* array = (unsigned char*)value;
775 for(int i = 0; i < sizeof(hdf_float64); i++) {
777 fscanf(fp, " %x", &tmp);
778 array[i] = (unsigned char)tmp;