#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
//由相对路径获得绝对路径,需在调用本函数处释放掉返回值指向的内存
char * get_file_path_absolute(char * file_path_relative)
{
char * path_absolute = NULL;
path_absolute = (char *)malloc(sizeof(char)*200);
memset(path_absolute,0, sizeof(char)*200);
if(file_path_relative[0] == '/')
{
strcpy(path_absolute,file_path_relative);
return path_absolute;
}
getcwd(path_absolute,200);
strcat(path_absolute, "/");
path_absolute = strcat(path_absolute,file_path_relative);
return path_absolute;
}