我正在将我的C ++ OpenGL应用程序移植到iOS,它使用getcwd函数来加载着色器。在iOS中'getcwd'只返回一个斜线,我无法做某事。或者有什么好方法可以在iOS上加载文件吗?
编辑:找到了解决方案!基于POSIX的代码。
static char homePath[256];
char *DocumentsFolder(void)
{
char *p;
if (*homePath)
return homePath;
if ((p = getenv("HOME")) != NULL) {
strncpy(homePath, p, sizeof(homePath));
strcat(homePath, "/Documents" );
if (mkdir(homePath, 0777)) {
if (errno != EEXIST)
printf( "CAN NOT CREATE DIRECTORY\n" );
}
return homePath;
}
return "";
}