Skip to content

Instantly share code, notes, and snippets.

@ryonagana ryonagana/path.c
Created Jul 23, 2019

Embed
What would you like to do?
char *path_data_folder(const char *folder, const char *file)
{
ALLEGRO_PATH *exe_path = NULL;
ALLEGRO_PATH *path = NULL;
ALLEGRO_PATH *data_dir = NULL;
char copy_path[2048];
exe_path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
strncpy(copy_path,"",2048);
strncat(copy_path, folder, strlen(folder));
strncat(copy_path,"/", strlen(folder));
strncat(copy_path, file, strlen(file));
path = al_create_path(copy_path);
data_dir = al_create_path("data/");
al_join_paths(data_dir,path);
al_join_paths(exe_path, data_dir);
const char *full_path = al_path_cstr(exe_path, ALLEGRO_NATIVE_PATH_SEP );
size_t size = strlen(full_path) + 1;
char *ret = calloc(size, sizeof(char)); //malloc(sizeof(char) * strlen(full_path) + 1);
memset(ret,'\0', sizeof(char) * size);
strncpy(ret, full_path, strlen(full_path));
al_destroy_path(path);
al_destroy_path(data_dir);
CB_free((void*) &full_path);
return ret;
//path = al_create_path( al_join_paths('') )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.