2013-06-09 12:07:45 +00:00
|
|
|
#include "data.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
static const char* _datapath = NULL;
|
|
|
|
|
|
|
|
static int _tryDataPath(const char* path)
|
|
|
|
{
|
|
|
|
char* buffer;
|
|
|
|
|
2013-11-02 15:43:43 +00:00
|
|
|
buffer = (char*)malloc(sizeof (char) * (strlen(path) + 30));
|
2013-06-09 12:07:45 +00:00
|
|
|
strcpy(buffer, path);
|
|
|
|
strcat(buffer, "/.paysages_data");
|
|
|
|
|
|
|
|
FILE* f = fopen(buffer, "r");
|
|
|
|
free(buffer);
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
_datapath = path;
|
|
|
|
fclose(f);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int dataInit()
|
|
|
|
{
|
2013-06-16 17:06:10 +00:00
|
|
|
return _tryDataPath("./data") || _tryDataPath("/usr/share/paysages3d");
|
2013-06-09 12:07:45 +00:00
|
|
|
}
|