made POSIX compliant

This commit is contained in:
Celine Mercier
2016-03-21 11:33:06 +01:00
parent 383e738ab7
commit b04b4b5902
8 changed files with 48 additions and 26 deletions

View File

@ -17,16 +17,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <unistd.h>
#include "private_at_functions.h"
#include "obidebug.h"
#include "obierrno.h"
#include "obidms.h"
#define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?)
char* get_full_path(int directory_file_descriptor, const char* path_name)
char* get_full_path(OBIDMS_p dms, const char* path_name)
{
char* full_path;
@ -37,26 +39,28 @@ char* get_full_path(int directory_file_descriptor, const char* path_name)
return NULL;
}
if (fcntl(directory_file_descriptor, F_GETPATH, full_path) < 0)
if (getcwd(full_path, MAX_PATH_LEN) == NULL)
{
obidebug(1, "\nError getting the path to a file or directory");
return NULL;
}
// TODO check errors?
strlcat(full_path, "/", MAX_PATH_LEN);
strlcat(full_path, path_name, MAX_PATH_LEN);
strcat(full_path, "/");
strcat(full_path, dms->directory_name);
strcat(full_path, "/");
strcat(full_path, path_name);
return full_path;
}
DIR* private_opendirat(int directory_file_descriptor, const char* path_name)
DIR* opendir_in_dms(OBIDMS_p dms, const char* path_name)
{
char* full_path;
DIR* directory;
full_path = get_full_path(directory_file_descriptor, path_name);
full_path = get_full_path(dms, path_name);
if (full_path == NULL)
return NULL;