Patch a bug when creating a DMS not in the current directory. Use the

basename function to locate the DMS name instead of the loop...
This commit is contained in:
2017-07-28 15:56:21 +02:00
parent b9c65a871f
commit 7c0d882bc9

View File

@ -19,6 +19,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h> #include <dirent.h>
#include <unistd.h> #include <unistd.h>
#include <libgen.h> /* <EC> : Addted the 28 july 2017 to include basename */
#include "obidms.h" #include "obidms.h"
#include "obierrno.h" #include "obierrno.h"
@ -160,7 +161,9 @@ int create_dms_infos_file(int dms_file_descriptor, const char* dms_name)
return -1; return -1;
// Create file // Create file
infos_file_descriptor = openat(dms_file_descriptor, file_name, O_RDWR | O_CREAT | O_EXCL, 0777); infos_file_descriptor = openat(dms_file_descriptor,
file_name,
O_RDWR | O_CREAT | O_EXCL, 0777);
if (infos_file_descriptor < 0) if (infos_file_descriptor < 0)
{ {
obi_set_errno(OBIDMS_UNKNOWN_ERROR); obi_set_errno(OBIDMS_UNKNOWN_ERROR);
@ -302,6 +305,7 @@ OBIDMS_p obi_create_dms(const char* dms_path)
return NULL; return NULL;
} }
/*
// Isolate the dms name // Isolate the dms name
j = 0; j = 0;
for (i=0; i<strlen(dms_path); i++) for (i=0; i<strlen(dms_path); i++)
@ -310,9 +314,10 @@ OBIDMS_p obi_create_dms(const char* dms_path)
j = i+1; j = i+1;
i++; i++;
} }
*/
// Create the informations file // Create the informations file
if (create_dms_infos_file(dms_file_descriptor, dms_path+j) < 0) if (create_dms_infos_file(dms_file_descriptor, basename(dms_path)) < 0)
return NULL; return NULL;
return obi_open_dms(dms_path); return obi_open_dms(dms_path);
@ -340,6 +345,7 @@ OBIDMS_p obi_open_dms(const char* dms_path)
return NULL; return NULL;
} }
/*
// Isolate and store the dms name // Isolate and store the dms name
j = 0; j = 0;
for (i=0; i<strlen(dms_path); i++) for (i=0; i<strlen(dms_path); i++)
@ -348,7 +354,8 @@ OBIDMS_p obi_open_dms(const char* dms_path)
j = i+1; j = i+1;
i++; i++;
} }
strcpy(dms->dms_name, dms_path+j); */
strcpy(dms->dms_name, basename(dms_path));
// Build and check the directory name including the relative path // Build and check the directory name including the relative path
complete_dms_path = build_directory_name(dms_path); complete_dms_path = build_directory_name(dms_path);