Add function to get an absolute path from a relative one

This commit is contained in:
X7123M3-256 2017-01-14 12:39:38 +00:00 committed by Ted John
parent e496271859
commit 3b12e4cc66
2 changed files with 14 additions and 0 deletions

View File

@ -167,6 +167,7 @@ bool platform_original_game_data_exists(const utf8 *path);
time_t platform_file_get_modified_time(const utf8* path);
bool platform_ensure_directory_exists(const utf8 *path);
bool platform_directory_delete(const utf8 *path);
char* platform_get_absolute_path(const char* relative_path,const char* base_path);
bool platform_lock_single_instance();
sint32 platform_enumerate_files_begin(const utf8 *pattern);
bool platform_enumerate_files_next(sint32 handle, file_info *outFileInfo);

View File

@ -262,6 +262,19 @@ bool platform_directory_delete(const utf8 *path)
return true;
}
char* platform_get_absolute_path(const char* relative_path,const char* base_path)
{
char path[MAX_PATH];
//This is to get around the fact that dirname() doesn't take a const char*
char base_path_copy[MAX_PATH];
safe_strcpy(base_path_copy,base_path,MAX_PATH);
snprintf(path,MAX_PATH,"%s/%s",dirname(base_path_copy),relative_path);
return realpath(path,NULL);
}
bool platform_lock_single_instance()
{
char pidFilePath[MAX_PATH];