// 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);
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()) ;
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);
};