paysages3d/src/rendering/tools/data.cpp

35 lines
586 B
C++
Raw Normal View History

#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;
buffer = (char*)malloc(sizeof (char) * (strlen(path) + 30));
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");
}